Write a C program
to calculate the area of following: -
1]Circle
2]Rectangle3]Triangle
#include<stdio.h>
#include<conio.h>
#include<math.h>
void
main()
{
int ch;
clrscr();
while(1)
{
printf("\n1. For are of triangle");
printf("\n2. For area of circle");
printf("\n3. For area of
ractangle");
printf("\n4. For are of square");
printf("\n5.exit");
printf("\nEnter your choice:");
scanf("%d",&ch);
switch(ch)
{
case 1:
{
int b,h,area;
printf("Enter base and height:");
scanf("%d%d",&b,&h);
area=(b*h)/2;
printf("The aree of
triangle=%d",area);
break;
}
case 2:
{
float r,area;
printf("Enter readius");
scanf("%g",&r);
area=3.14594*r*r;
printf("\n area of
circle=%g",area);
break;
}
case 3:
{
int l,b,area;
printf("Enter lenght and
breadth:");
scanf("%d%d",&l, &b);
area=l*b;
printf("Area of
rectangle:%d\n",area);
break;
}
case 4:
{
int area,l;
printf("Enter lenght:");
scanf("%d",&l);
area=l*l;
printf("The are of
square:%d",area);
break;
}
case 5:
{
exit(0);
}
}
}
getch();
}
/* output
1. For are of
triangle
2. For area of
circle
3. For area of
ractangle
4. For are of
square
5.exit
Enter your
choice:1
Enter base and
height:4
6
The aree of
triangle=12
1. For are of
triangle
2. For area of
circle
3. For area of
ractangle
4. For are of
square
5.exit
Enter your
choice:2
Enter readius4
area of circle=50.335
1. For are of
triangle
2. For area of
circle
3. For area of
ractangle
4. For are of
square
5.exit
Enter your
choice:3 */