#include
#include
void main()
{
int a=0,b,pi=3.14,r,h,n;
clrscr();
printf("enter r:");
scanf("%d",&r);
printf("enter b:");
scanf("%d",&b);
printf("enter h:");
scanf("%d",&h);
printf("\nenter 1 for circle\nenter 2 for square\nenter 3 for rectangle\nenter 4 for triangle\n");
printf("enter choice:");
scanf("%d",&n);
switch (n)
{
case 1:
a=pi*r*r;
printf("area of circle is %d",a);
break;
case 2:
a=4*b;
printf("area of square is %d",a);
break;
case 3:
a=2*b*h;
printf("area of rectangle is %d",a);
break;
case 4:
a=(b/2)*h;
printf("area of triangle is %d",a);
break;
default:
printf("bug");
break;
}
getch();
}
17 comments:
i think you should check the logic of program accepting data before option is not correct logic.
true
true
its too long..
you should use float instead of int
coz answer of circle and triangle area cant be in integer
Float expressions are not allowed in switch case
True
Where is output?. .
Output
Output
Poke you
Yeah that's true bae
Out put
Out put
Output
your program is right but the formula is of perimeter or circumference not area.
Output
Post a Comment