Computer Science, asked by hemudharu494, 1 month ago

C Program to find area/volume of geometrical shapes (Circle, Triangle-given three sides, given base and height

Answers

Answered by dreamrob
1

Program:

#include<stdio.h>

#include<conio.h>

#include<math.h>

int main()

{

float r, a, b, c, base, height, A, s;

printf("Enter the radius of circle : ");

scanf("%f", &r);

A = 3.14 * r * r;

printf("Area of circle = %f \n", A);

printf("\nEnter the length of the sides of the triangle : ");

scanf("%f", &a);

scanf("%f", &b);

scanf("%f", &c);

s = (a + b + c) / 2;

A = sqrt(s * (s - a) * (s - b) * (s - c));

printf("Area of triangle = %f \n", A);

printf("\nEnter the base and height of the sides of the triangle : ");

scanf("%f", &base);

scanf("%f", &height);

A = (1.0 / 2.0) * base * height;

printf("Area of triangle = %f \n", A);

return 0;

}

Output:

Enter the radius of circle : 8

Area of circle = 200.960007

Enter the length of the sides of the triangle : 3 6 7

Area of triangle = 8.944272

Enter the base and height of the sides of the triangle : 5 8

Area of triangle = 20.000000

Similar questions