Calculate volume of sphere - C Program

C program to read radius of sphere and calculate its volume.

Solution:

Formula: Volume of sphere= 4/3 * 3.14 * r * r * r

Here, r is radius of sphere.

Note - While writing formula in program, typecasting is very important. Because it affects the result.

#include<stdio.h>
int main()
{
     int r;
     float volume_sphere;
     printf("Enter Radius : ");
     scanf("%d",&r);
     volume_sphere = (4/3.0)*3.14*r*r*r;
     printf("\nVolume of Sphere = %f",volume_sphere);
     return 0;
}


Output:

volume of sphere