# 14 : C Program to Calculate Volume of Sphere

Check out the complete list of c-programs : C Program List

To calculate the volume of Sphere you need to ask user to enter radius of sphere. PI value is needed to calculate the volume.

Variables :

1. radius : (Datatype int) : to represent the radius of Sphere.

2. PI : (Datatype float) : static variable to represent constant PI value upto 3 decimal places i.e 3.142

3. volume_of_sphere : (Datatype float) : to store volume of Sphere calculated.

Functions :

printf() : is used to display something on the console/screen. Format specifier %d in printf function is used to display a int variable on screen and %f for float. \n is used to add a newline

scanf() : is used to fetch data inputted by the user on the console/screen using keyboard. %d in scanf is indicates that inputted text is of type int and %f for float.

Formula :

Volume of a Sphere : (4/3) x π x r3

``````
/*
* 1000+ C programs + tutorials
*
*
* 14_calculate_volume_of_sphere.c
*
*
*  Created on: Oct 20, 2014
*  Author: Code2care.org
*/

#include <stdio.h>
//#include <conio.h>

void main() {

float volume_of_sphere;
float PI = 3.142;

//	clrscr();

printf(" Program to calculate Volume of a Sphere :  ");

printf("\n\n Enter the Radius of Sphere : ");

//	getch();

}```
```

• Output :

Program to calculate Volume of a Sphere :

Enter the Radius of Sphere : 2

Volume of Sphere with Radius as 2 = 25.136000

The best way to learn C programming is to practice more and more of programs . Code2care C Programming tutorials provide 1000+ programs in C that you can study and become an expert in the language. Programs are divided into categories depending upon type and complexity.

BSc. IT, BSc. Computer Science, BSc. IT, MSc. IT, MSc. Computer Science, MCA, BTech IT & BTech Engineers may find these programs very useful.