C program to calculate area and circumference of a circle

This C program calculates and prints the area and circumference of a circle. The user enters the radius of the circle.

Basic Mathematics :

Area of a circle – π * r * r , where π = 22/7 or 3.14

Circumference of a circle = 2 * π * r

Program: C program to calculate area and circumference of a circle

#include<stdio.h>       
                
int main()       
                
{        
                
    float r,area,cir;       
                
 printf("Enter the radius of the circle:");       
                
 scanf("%f",&r); /* to allow the user to enter the radius of the circle*/       
                
 area=3.14*r*r; /* to calculate the area*/       
                
 cir=2*3.14*r; /* to calculate the circumference*/       
                
 printf("\nArea of the given circle is :%f",area);       
                
 printf("\nCircumference of the given circle is :%f\n",cir);       
                
 return 0;       
 }

Output:

Enter the radius of the circle:5

Area of the given circle is :78.500000
Circumference of the given circle is :31.400000

About ᴾᴿᴼᵍʳᵃᵐᵐᵉʳ

Linux and Python enthusiast, in love with open source since 2014, Writer at programming-articles.com, India.

View all posts by ᴾᴿᴼᵍʳᵃᵐᵐᵉʳ →

Leave a Reply

Your email address will not be published. Required fields are marked *