forked from sharunrajeev/YourFirstContribution
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharea.c
54 lines (52 loc) · 940 Bytes
/
area.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
48
49
50
51
52
53
54
#include <stdio.h>
int input();
void output(float);
int main()
{
float result;
int choice, num;
printf("Press 1 to calculate area of circle\n");
printf("Press 2 to calculate area of square\n");
printf("Press 3 to calculate area of sphere\n");
printf("Enter your choice:\n");
choice = input();
switch (choice) {
case 1: {
printf("Enter radius:\n");
num = input();
result = 3.14 * num * num;
printf("Area of sphere=");
output(result);
break;
}
case 2: {
printf("Enter side of square:\n");
num = input();
result = num * num;
printf("Area of square=");
output(result);
break;
}
case 3: {
printf("Enter radius:\n");
num = input();
result = 4 * (3.14 * num * num);
printf("Area of sphere=");
output(result);
break;
}
default:
printf("wrong Input\n");
}
return 0;
}
int input()
{
int number;
scanf("%d", &number);
return (number);
}
void output(float number)
{
printf("%f", number);
}