#include <stdio.h>
#include <conio.h>
#include <math.h>
void main()
{
int a;
float b, h, hg, ans;
printf("[1] area of Triangle\n");
printf("[2] area of rectangle\n");
printf("[3] area of square\n");
printf("[4] area of circle\n");
printf("[5] area of cone \n");
printf("Select a option from above: \n");
scanf("%d", &a);
switch (a)
{
case 1:
printf("enter a value of base: ");
scanf("%f", &b);
printf("enter a value of height: ");
scanf("%f", &h);
ans = ((b * h) / 2);
printf("the area of traingle is %.2f \n", ans);
break;
case 2:
printf("enter a value of length: ");
scanf("%f", &b);
printf("enter a value of breadth: ");
scanf("%f", &h);
ans = b * h;
printf("the area of rectangle is %.2f \n", ans);
break;
case 3:
printf("enter a value of length: ");
scanf("%f", &b);
ans = b * b;
printf("the area of square is %.2f \n", ans);
break;
case 4:
printf("enter a value of pie: ");
scanf("%f", &b);
printf("enter a value of radius: ");
scanf("%f", &h);
ans = b * h * h;
printf("the area of circle is %.2f \n", ans);
break;
case 5:
printf("enter a value of pie: ");
scanf("%f", &b);
printf("enter a value of radius: ");
scanf("%f", &h);
printf("enter a value of S.height: ");
scanf("%f", &hg);
ans = (b * h * h) + (b * h) * hg;
printf("the area of cone is %f \n", ans);
// 3.1415 * 7 * 7 = 153.9335 +
// 3.1415 * 7 = 21.9905*10 = 219.905
// 219.905 + 153.9335
// 373.8385
break;
default:
printf("option is not available\n");
break;
}
}
OUTPUT
[1] area of Triangle
[2] area of rectangle
[3] area of square
[4] area of circle
[5] area of cone
Select an option from above:
5
enter a value of pie: 3.1415
enter a value of radius: 7
enter a value of S.height: 10
the area of a cone is 373.838501
0 Comments