Calculate Volume of Sphere

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


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

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

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

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:

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

void main() {

    int radius;
    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 : ");
	scanf("%d", &radius);
    volume_of_sphere = (4/3)*(PI*radius*radius*radius);

	printf("\n\n Volume of Sphere with Radius as %d = %f",radius,volume_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

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.

Recent Posts:
Hello there!,

You are using AdBlocker!

I am an independent developer trying to help fellow developers and students to resolve issues faced on a day-to-day basis, we 'Code to Care' . There is a lot of expenses involved in hosting and managing a website that's the reason we have ads.

A humble request to you to disable adBlocker on and support us pay our bills.

Cod2ecare - Line's of code for change.

To see contents reload page after unblocking
Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.