-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharea_square_rectangle_circle.c
More file actions
41 lines (38 loc) · 1.21 KB
/
area_square_rectangle_circle.c
File metadata and controls
41 lines (38 loc) · 1.21 KB
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
#include <stdio.h>
#include <math.h>
// define a function for calculation of "Area of square"
float area_of_square(float x) {
printf(" Area of Square %f \n", pow(x, 2));
}
// define a function for calculation of "Area of Rectangle"
float area_of_rectangle(float x,float y) {
printf(" Area of Rectangle %f %f \n", x * y);
}
// define a function for calculation of "Area of Circle"
float area_of_circle(float r) {
float pi = 3.14;
printf(" Area of Circle %f \n", pi*pow(r, 2));
}
int main() {
float l;
float r;
float w;
float L;
// Ask to user enter the "Length" for calculation of area of square
printf("Enter only 'Length' for calculation of 'area of square': ");
scanf("%f", &l);
// Ask to user enter the "weight" for calculation of area of rectangle
printf("Enter 'weight' and 'Length' for calculation of area of rectangle: ");
scanf("%f %f", &w, &L);
// Ask to user enter the "radius" for calculation of area of circle
printf("Enter 'radius' for calculation of area of circle: ");
scanf("%f", &r);
if(l){
area_of_square(l);
} if(l, w) {
area_of_rectangle(l, w);
} if(r) {
area_of_circle(r);
}
return 0;
}