forked from Tomkndn/C
-
Notifications
You must be signed in to change notification settings - Fork 2
/
area_of_shapes.c
47 lines (41 loc) · 1 KB
/
area_of_shapes.c
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
38
39
40
41
42
43
44
45
46
47
#include<stdio.h>
void square(float A);
void rectangle(float A, float B);
void circle(float A);
int main(){
char A;
int B,C,D,E;
printf("<<Finding the Area of Square, Rectangle or Circle!!!!.>>\n");
printf("Enter s for Square, r for Rectangle, c for Circle: ");
scanf("%c", &A);
if (A == 's')
{
printf("Enter the sides for Square: ");
scanf("%d", &B);
square(B);
}else if (A == 'r')
{
printf("Enter the sides for Rectangle: ");
scanf("%d %d", &B, &D);
// printf("Enter the second side for Rectangle: ");
// scanf("%d", &D);
rectangle(B, D);
}else{
printf("Enter the radius for Circle: ");
scanf("%d", &E);
circle(E);
}
return 0;
}
void square(float A){
float X = A*A;
printf("Your Area is %.2f", X);
}
void rectangle(float A, float B){
float X = A*B ;
printf("Your Area is %.2f", X);
}
void circle(float A){
float X = 3.14*A*A;
printf("Your Area is %.2f", X);
}