-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsample1.c
52 lines (46 loc) · 1.02 KB
/
sample1.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
/* prog 13-1,................. */
double area(int),circumf(int);
double volume(int),surface(int);
int main(void)
{
int r,item;
printf("(1) ... (2) ...\n");
printf("(3) .... (4) .....\n");
printf(".........:");
do
scanf("%d",&item);
while((item>4)||(item<1));
do
{
printf("....:");
scanf("%d",&r);
} while(r<=0);
printf("\n");
switch (item)
{
case 1:printf("..=%d,...=%.2f\n",r,area(r));
break;
case 2:printf("..=%d,...=%.2f\n",r,circumf(r));
break;
case 3:printf("..=%d,....=%.2f\n",r,volume(r));
break;
case 4:printf("..=%d,.....=%.2f\n",r,surface(r));
}
return 0;
}
double area(int r) /* ....area()...... */
{
return (PI*r*r);
}
double volume(int r)/* ....volume()....... */
{
return (4/3*PI*r*r*r);
}
double surface(int r)/* ....surface()........ */
{
return (4*PI*r*r);
}
double circumf(int r)/* ....circumf()...... */
{
return (2*PI*r);
}