UMBC CMSC 104
UMBC CMSC 104 Spring 2001 CSEE | 104 | current 104

CMSC 104, Spring 2001

Project 5 - The Equilateral Triangle

Due Date:

Midnight, Thursday April 5

Note: No late projects will be accepted.

Point Value:

This assignment is worth 50 points.

Objectives:

Assignment:

You are to write a program that computes and displays the area and the perimeter of an equilateral triangle, given the length of one of its sides. Get the length of the side from the user.

Part 1 - The Pseudocode (10 points)

First, write the pseudocode to solve the problem. Be sure that your pseudocode includes the greeting, user prompt, and output labels shown in the sample run below. Type the pseudocode in to a file called p5pseudo.txt.

Part 2 - The C Code (40 points)

Next, write the corresponding C program. Call it proj5.c. Use floating point variables for all values.

The output from your program should look EXACTLY like the bolded text in the sample run given below. Also make sure that the spacing of the output (i.e., blank lines and blanks spaces) is EXACTLY like the spacing in the sample run. Here is the sample run:

This is the Equilateral Triangle Program

Enter the length of a side: 3.5

Side Length = 3.500000
Area = 5.304405
Perimeter = 10.500000

Make sure to test your program by running it several times with different values for the side. Verify the results by using a calculator. (Note that the last few digits for each value may differ when using a calculator. That is OK.) You may assume that the user will type in a value greater than 0.0 for the length of the side.

Hint: You can find the predefined function sqrt (to find the square root of a number) in the math.h library.

Compile your program as follows:

gcc -ansi -Wall -lm proj5.c

This is a little different than what you did in Project 4. Note the inclusion of the -lm option on the command line. This option tells the linker to include the math library. Without it, any predefined mathematical function, such as sqrt,, will not be able to be located by the linker and you will receive an error message.

Coding Standards:

Note that you MUST adhere to the coding standards and indentation style given on the Projects home page. So read them carefully and immediately!

Project Submission:

Submit your project by e-mailing your pseudocode (p5pseudo.txt) and source code (proj5.c) to Evelyn (cwang3@cs.umbc.edu) as attachments. Make the Subject of the e-mail Project 5 so that Evelyn knows what it is. Do NOT send your executable file (a.out).


Last Modified: Wednesday, 04-Apr-2001 14:54:27 EDT

Wednesday, 04-Apr-2001 14:54:27 EDT