C program to display area of geometric shapes using switch case

C program to display area of geometric shapes using switch case


 *********************************************

 C program to display area of geometric shapes using switch case

 ***************************************************/

#include<stdio.h>

#include<conio.h>

void main()

{

    int choice;

    int r,l,b,base,height,s,area;

    clrscr();

    printf("Enter radius, length, breadth, base, height and side\n");

    scanf("%d%d%d%d%d%d",&r,&l,&b,&base,&height,&s);

    printf("Enter your choices as mentioned below to display area of geometric    shapes\n");

    printf("For Area of circle : 1\n");

    printf("For Area rectangle : 2\n");

    printf("For Area of triangle : 3\n");

    printf("For Area of square : 4\n");

    printf("Enter your choice to perform operation\n");

    scanf("%d",&choice);

    switch(choice)

    {

        case 1:

        area=3.14*r*r;

        printf("The area of circle is:%d\n",area);

        break;

        case 2:

        area=l*b;

        printf("The area of rectangle is:%d\n",area);

        break;

        case 3:

        area=0.5*base*height;

        printf("The area of triangle is:%d\n",area);

        break;

        case 4:

        area=s*s;

        printf("The area of square is:%d\n",area);

        break;

        default:

        printf("The choice is invalid please enter valid choice\n");

        break;

    }

    printf("End of program");

  

}


Enter radius, length, breadth, base, height and side

2

3

2

3

2

3

Enter your choices as mentioned below to display area of geometric shapes

For Area of circle : 1

For Area rectangle : 2

For Area of triangle : 3

For Area of square : 4

Enter your choice to perform operation

4

The area of square is:9

End of program



टिप्पणी पोस्ट करा

0 टिप्पण्या