# How to calculate the volume of a sphere using C programming language?

CServer Side ProgrammingProgramming

#### C in Depth: The Complete C Programming Guide for Beginners

45 Lectures 4.5 hours

#### Practical C++: Learn C++ Basics Step by Step

Most Popular

50 Lectures 4.5 hours

#### Master C and Embedded C Programming- Learn as you go

66 Lectures 5.5 hours

The volume of sphere is nothing but the capacity of the shape.

Volume of a sphere formula is −

$$V\:=\:\frac{4}{3}\Pi\:r^{3}$$

## Algorithm

Step 1: Enter radius of sphere at runtime
Step 2: Apply the formula to variable
Step 3: print the volume
Step 4: stop

## Program 1

Live Demo

#include<stdio.h>
int main(){
float vol;
printf("the volume of a sphere is %f\n",vol);
return 0;
}

## Output

the volume of a sphere is 33509.335938

## Program 2

Following is an example to find Volume and Surface Area of Sphere −

Live Demo

#include <stdio.h>
#include <math.h>
int main(){
float area, vol;
printf("Enter radius of the sphere : \n");
printf("Surface area of sphere is: %.3f", area);
printf("\n Volume of sphere is : %.3f", vol);
return 0;
}

## Output

Enter radius of the sphere :
4
Surface area of sphere is: 192.000
Volume of sphere is : 256.000
Updated on 05-Mar-2021 08:35:37