Surface_area = 4 * Pi * r2, Volume = 4/3 * Pi * r3 where r is the radius of the sphere, Pi= 22/7
Here is source code of the C Program to Find the volume and surface area of sphere.
The C program is successfully compiled and run on a Linux system. The program output is also shown below.
* C Program to Find Volume and Surface Area of Sphere
float surface_area, volume;
printf("Enter radius of the sphere : \n");
surface_area = 4 * (22/7) * radius * radius;
volume = (4.0/3) * (22/7) * radius * radius * radius;
printf("Surface area of sphere is: %.3f", surface_area);
printf("\n Volume of sphere is : %.3f", volume);
Output: $ cc pgm30.c $ a.out Enter radius of the sphere : 40 Surface area of sphere is: 19200.000 Volume of sphere is : 256000.000
Sanfoundry Global Education & Learning Series – 1000 C Programs.