Saturday, November 23, 2019

Write a program in C which is a Menu-Driven Program to compute the area of the various geometrical shape

#include<stdio.h>
int main ()
{
      int input_choice;
      int radious;
      int length,width;
      int base,hight;
      float area=0;

      printf("Enter 1 for area of circle\n");
      printf("Enter 2 for area of rectangle\n");
      printf("Enter 3 for area of triangle\n");
      printf("Enter your choice : ");
      scanf("%d",&input_choice);
      switch(input_choice)
      {
           case 1:
                 printf("Input radious of the circle : ");
                 scanf("%d",&radious);
                 area=3.14*radious*radious;
                 break;
            case 2:
                  printf("Input length and width of the rectangle : ");
                  scanf("%d \n %d ",&length,&width);
                  area=length*width;
                  break;
            case 3:
                  printf("Input the base and hight of the triangle :");
                  scanf("%d \n %d",&base,&hight);
                  area=(0.5)*base*hight;
                  break;
        
            default:
                  printf("select the correct choice\n");   
    }
          printf("The area is : %f\n",area);
          return 0;
}


OUTPUT:

Enter 1 for area of circle
Enter 2 for area of rectangle
Enter 3 for area of triangle
Enter your choice : 1
Input radious of the circle : 4
The area is : 50.240002

Enter 1 for area of circle
Enter 2 for area of rectangle
Enter 3 for area of triangle
Enter your choice : 5
select the correct choice
The area is : 0.000000







No comments:

Post a Comment