Skip to main content

C Program to Calculate Area of circle, circumference , volume of sphere

Program is accepting radius of circle and using below formula

area of circle : A=πr2

Circumference of circle = 2πr

Volume of Sphere = V=4/3 πr3

//Program name: Calculate Area, Circumference of Circle and Volume of sphere

#include<stdio.h>
#include<conio.h>

#define pi 3.14        //constant decleration

void main()
{    int r,op;
     float c_area,c_circumference,c_Vsphere;
     printf("\nEnter Radius of Circle to Calculate area, Circumference : ");
     scanf("%d",&r);

     printf("\n\t1) Area of Circle. \n\t2) Circumference of circle.\n\t3) Volume of Sphere.");
     printf("\n\n\tSelect  Option : ");
     scanf("%d",&op);
     switch(op)
	{  case 1:  c_area=(float) pi*r*r;
		    printf("\n\n\tArea of Circle = %.2f ",c_area);
		    break;
	   case 2:  c_circumference=(float) 2*pi*r;
		    printf("\n\n\tCircumference of circle = %.2f ",c_circumference);
		    break;
	   case 3:  c_Vsphere=(float) 4/3*pi*r*r*r;
		    printf("\n\n\tVolume of Sphere = %.2f ",c_Vsphere);
		    break;
	   default: printf("\n\t Invalid option ");

	}

}//main                                    

Output

Enter Radius of Circle to Calculate area, Circumference : 7

        1) Area of Circle. 
        2) Circumference of circle.
        3) Volume of Sphere.

        Select  Option : 1

        Area of Circle = 153.86 
 	
	Select  Option : 2

	Circumference of circle. = 43.96

	Select  Option : 3

	Volume of Sphere. = 1436.03