Code programs to calculate the following:

a) Area of a square

b) Area of a rectangle

c) Area of a triangle

d) Area of a circle

main()

{

printf("Please enter your choice\n");

printf("1)Area of a square\n2) Area of a rectangle\n");

printf("3) Area of a triangle\n4) Area of a circle\n");

int ch;

scanf("%d",&ch);

float a,s,l,b,B,h,r;

switch(ch)

{

case 1:

printf("enter length of side of square\n");

scanf("%f",&s);

a=s*s;

break;

case 2:

printf("enter Length and width of rectangle\n");

scanf("%f%f",&l,&b);

a=l*b;

break;

case 3:

printf("enter base and height of triangle\n");

scanf("%f%f",&B,&h);

a=0.5*B*h;

break;

case 4:

printf("enter radius of circle\n");

scanf("%f",&r);

a=3.1415*r*r;

break;

default:

printf("WRONG CHOICE !!!!!\n");

exit(0);

}

printf("Area=%f\n",a);

getch();

return 0;

}

## No comments:

## Post a Comment