C Program to find Volume and Surface Area of Sphere

How to write C Program to find Volume and Surface area of Sphere with example. Before we step into the C Program to find Volume and Surface Area of Sphere, Let see the definitions and formulas behind the Surface area of Sphere and Volume of Sphere

C Surface Area of Sphere

A Sphere looks like a basketball, or we can say the three-dimensional view of a circle. If we know the radius of the Sphere then we can calculate the Surface Area of Sphere using the formula:

Surface Area of a Sphere = 4πr² (Where r is the radius of the sphere).

From the above formula, If we know the Surface Area of a sphere, then we can calculate the radius of a Sphere using the formula:

Radius of a Sphere = √sa / 4π (Where sa is the Surface Area of a sphere).

C Volume of Sphere

The amount of space inside the sphere called Volume. If we know the radius of the Sphere then we can calculate the Volume of Sphere using the formula:

The volume of a Sphere = 4πr³

C Program to find Volume and Surface Area of Sphere

We defined pi as a global variable and assigned value as 3.14. This C program allows the user to enter the value of a radius. Then it will calculate the Surface Area and Volume of a Sphere as per the formula.

/* C Program to find Volume and Surface Area of Sphere */

#include <stdio.h>

#define PI 3.14

int main()
{
  float radius, sa,Volume;

  printf("\n Please Enter the radius of a Sphere \n");
  scanf("%f", &radius);

  sa =  4 * PI * radius * radius;
  Volume = (4.0 / 3) * PI * radius * radius * radius;

  printf("\n The Surface area of a Sphere = %.2f", sa);
  printf("\n The Volume of a Sphere = %.2f", Volume);

  return 0;
}
C Program to find Volume and Surface Area of Sphere

In this C program to find Volume and Surface Area of Sphere example, We have entered the Radius of a Sphere = 5

The Surface Area of a Sphere is
Surface Area = 4πr²
Surface Area = 4 * PI * radius * radius;
Surface Area = 4 * 3.14 * 5 * 5
Surface Area = 314

The Volume of a Sphere is
Volume = 4πr³
Volume = (4.0 / 3) * PI * radius * radius * radius;
Volume = (4.0 / 3) * 3.14 * 5 * 5 * 5;
Volume = 523.33333

Let us calculate the Radius of a Sphere using the Surface Area: In the above C Programming example, we got the Surface area of a Sphere = 314 when the radius = 5. Let us make the reverse approach (calculate the radius from Surface area = 5)

radius of a Sphere = √sa / 4π
radius of a Sphere = √314 / 4 * 3.14
radius of a Sphere = √314 / 12.56
radius of a Sphere = √25
radius of a Sphere = 5