forked from PrabhudeepSingh/C-Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAreaUsingSwitch.c
More file actions
37 lines (31 loc) · 988 Bytes
/
AreaUsingSwitch.c
File metadata and controls
37 lines (31 loc) · 988 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//Program to find area of circle, rectangle and triangle using switch statement
#include<stdio.h>
int main()
{
int a;
float base,height,length,breadth,radius;
printf("Enter your choice\n1 for Circle\n2 for Rectangle\n3 for triangle\n\nEnter here : ");
scanf("%d",&a);
printf("\n\n");
switch(a)
{
case 1 : printf("Enter the radius : ");
scanf("%f",&radius);
printf("\nArea of cicle = %.2f",3.14*radius*radius);
break;
case 2 : printf("Enter the length : ");
scanf("%f",&length);
printf("Enter th breadth : ");
scanf("%f",&breadth);
printf("\nArea of rectangle = %.2f",length*breadth);
break;
case 3 : printf("Enter the base : ");
scanf("%f",&base);
printf("Enter the height : ");
scanf("%f",&height);
printf("\nArea of Triangle = %.2f",0.5*base*height);
break;
default : printf("Invalid choice.");
}
return 0;
}