Question: 1. Write a Ch program that can be used to calculate and display the area and the perimeter of three different two dimensional geometric shapes:
1. Write a Ch program that can be used to calculate and display the area and the perimeter of three different two dimensional geometric shapes: a circle, a rectangle, and a triangle. Your program should be modular and must contain the following functions: Function main will be the program driver - it will repeatedly display a menu of shapes to the user asking the user to select one and then call the appropriate functions to prompt the user for input of dimension(s), read the dimension(s), calculate the area and perimeter, and display the results. The repetition should continue until the user selects to exit the program. Three overloaded getDim functions that will ask the user to enter the needed shape dimension(s) from the user and return the dimension(s) to main. Three overloaded area functions that will take in the shape dimension(s) and calculate and return the shape area. Three overloaded perimeter functions that will take in the shape dimension(s) and calculate and return the shape perimeter. One display function that will take a shape indicator value and the shape area and perimeter values and display the labeled results. I Note: Your program should use Heron's formula (given below) for finding the area of a triangle (the formula uses the triangle's side lengths instead of the base and the height to find the area). Note: Your program should also include a global named constant PI initialized to 3.141592654 that will be needed by your circle area and perimeter functions. Area and Perimeter Formulas: Circle: 4= 1? P= 2.77 where r is the circle radius. Rectangle: hu P = 22 + 2w where I and w are the rectangle length and width. Triangle: A = Vs(s -a)(5-b)(3-0). where s = a+b+c P=a+b+c 2 where a, b, and care the lengths of the sides of the triangle
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
