Tuesday, 4 September 2018

Program to calculate area of different shape in C using switch statement

#include<stdio.h>
void main ()
{
int choice,r,l,b,base,h,area1,area2,area3;
clrscr();
printf ("\n you can perform following operation:");
printf ("\n 1. Area of circle:");
printf ("\n 2. Area of rectangle:");
printf ("\n 3. Area of parallelogram;");
printf ("\n Enter your choice:");
scanf ("%d", &choice);
switch ( choice )
{
       case 1:
       printf ("\n Enter value of radius:");
       scanf ("%d", &r);
       area1 = 3.14*(r*r);
       printf ("%d", area);
break;
       case 2:
       printf ("\n Enter value of length:");
       scanf ("%d", &l);
       printf ("\n Enter value of breadth:");
       scanf ("%d", &b);
       area2 = l*b;
       printf ("%d", area2);
break;
       case 3:
       printf ("\n Enter value of base:");
       scanf ("%d", &base);
       printf ("\n Enter value of height:");
       scanf ("%d", &h);
       area3 = base*h;
       printf ("%d", area3);
break;
       default :
       printf ("\n Invalid number:");
}
getch ();
}
      








1 comment:

  1. Kanhasoft is leading Django Application Development Company in India and USA. We have a team of 45+ experienced Django developers to outsource our services. You can visit our site for more information.

    ReplyDelete

Featured post

Program to find Volume of given box in java

class volume { public static void main (String args []) { int l=5,b=6,h=10; int volume; volume=l*b*h; System.out.println (" vol...