Computers in Engineering WWW Site - Example 12.8

# Example 12.8

#### C Version

```/*
Program to calculate circumference, area, and volume
*/

#include <stdio.h>

main()
{
/*  Declaration Statements  */
double pi, circum, area, vol, r;
short n;

/*  Assignment Statements  */
clrscr();
printf("C48.C -> Program to calculate circumference, area and volume\n");
printf("\n");                         /*  This program will compute  */
pi = 3.14159;                         /*  circ.,area and volume with */
printf("Enter the radii : ");         /*  all radius from 1 to n by  */
scanf("%hd", &n);                     /*  step of 0.5                */
getchar();
printf("\n%6crad%6ccir%5carea%6cvol\n", ' ', ' ', ' ', ' ');

r = 1.0;
while (r <= n) {
circum = 2.0 * pi * r;
area = pi * r * r;
vol = 4.0 / 3.0 * pi * r * r * r;

/*  Print results  */
printf("%9.2f%9.2f%9.2f%9.2f\n", r, circum, area, vol);
r += 0.5;
}  /*  End of while{} loop  */
printf("\n");

return(0);
}
/*  End of Program C48  */
/*
```
INPUT :
``` 5

```
OUTPUT :
```
C48.C -> Program to calculate circumference, area and volume

1.00     6.28     3.14     4.19
1.50     9.42     7.07    14.14
2.00    12.57    12.57    33.51
2.50    15.71    19.63    65.45
3.00    18.85    28.27   113.10
3.50    21.99    38.48   179.59
4.00    25.13    50.27   268.08
4.50    28.27    63.62   381.70
5.00    31.42    78.54   523.60

*/
```