/* Triangle Properties (15 points) Problem Statement: Given parameters b and h which stand for the base and the height of an isosceles triangle (i.e., a triangle that has two equal sides), write a C program that calculates: * the area of the triangle * the perimeter of the triangle * the volume of the cone formed by spinning the triangle around the line h The program must prompt the user to enter b and h. The program must define and use the following three functions: getArea(base, height) //calculates and returns the area of the triangle getPerimeter(base, height) //calculates and returns the perimeter getVolume(base, height) //calculates and returns the volume Format the results so that only three digits after the decimal point are displayed. Math refresher: Isosceles triangle ^ /|\ area = (b*h)/2 a / | \ a perimeter = b + 2*a / |h \ volume = (1/3)*(area of cone's base)*(height) / | \ --------- b Checking with base=6, height=4: Area = 12.000 Petimeter = 16.000 Volume = 37.699 */ #include #include #include float getArea(float b, float h) { return (b*h)/2.0; } float getPerimeter(float b, float h) { float a; // first find a which is unknown a = sqrt( (b/2)*(b/2) + h*h ); return b + 2*a; } float getVolume(float b, float h) { float area=M_PI*pow(b/2,2); return (1.0/3.0)*area*h; } int main() { float height, base; float area, perimeter, volume; printf("Input the base of the Isosceles triangle: "); scanf("%f", &base); printf("Input the height of the Isosceles triangle: "); scanf("%f", &height); area = getArea(base, height); perimeter = getPerimeter(base, height); volume = getVolume(base, height); printf("\n\n"); printf("Area = %7.3f\n", area); printf("Perimeter = %7.3f\n", perimeter); printf("Volume = %7.3f\n\n", volume); system("pause"); }