C Program to Find Volume of a Sphere

This program calculates the volume of a sphere using the formula (4/3) × π × r³. The value of π is defined as a constant in C.

Concept Overview

The volume of a sphere is calculated using simple mathematical formula: Volume = (4/3) × π × r³. In C, we can define π as a constant and perform these calculations easily.

Program

#include <stdio.h>
#define PI 3.1415

int main() {
    float radius, volume;

    printf("Enter the radius of the sphere: ");
    scanf("%f", &radius);

    volume = (4.0 / 3.0) * PI * radius * radius * radius;

    printf("Volume of the sphere is: %f\n", volume);

    return 0;
}

Output

Volume of the sphere with radius 5 is 523.583333

Explanation