• Language

    C

  • Description

    Calculates the volume of a sphere having its radius

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>

int main (void)
{
    float radius, volume;
    printf ("Enter the value of radius: ");
    scanf ("%f", &radius);
    (void) getchar ();
    volume=4.0*M_PI*radius*radius*radius/3.0;
    printf ("Value of volume: %g\n", volume);
    putchar ('\n');
    system ("pause");
    return EXIT_SUCCESS;
}