C Program to Compute Volume and Surface Area of Sphere

C Program to Compute Volume and Surface Area of Sphere

Write C Program to Compute the Volume and the Surface Area of a Sphere

//Write a C Program to Compute Volume and Surface Area of Sphere

#include <stdio.h>
#define PI 3.14

int main()
{
   float radius = 4;

   double area_sphere;
   // Formula to compute area of sphere
   area_sphere = 4 * PI * (radius * radius);


   double volume;
   // Formula to compute volume of sphere
   volume = (4 * PI * radius * radius * radius)/3;

   printf("Surface area of Sphere having radius %0.2f :--> %0.2f ", radius, area_sphere);
   printf("\nVolume of Sphere having radius %.2f :--> %.2f ",radius, volume);

   return 0;
}

Output:

Surface area of Sphere having radius 4.00 :--> 200.96
Volume of Sphere having radius 4.00 :--> 267.95