C Programming

C Program to calculate the area and circumference of a circle

These are the different ways to calculate the area and circumference of the circle in C programming.

#include<stdio.h>
#include<conio.h>
#define pi 3.14

void main()
{
int r;
float a, c;

printf("ntenter value of radius=");
scanf("%d",&r);

a= pi*r*r;
c=2*pi*r;

printf("tArea = %.2fn",a);
printf("tCircumference = %.2fn",c);

getch();

}

Output

calculate area and circumference of circle

 You can also perform this calculate by defining pi as float value.   

C Code

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

void main()
{
int r;
float a, c;
float pi=3.14;

printf("ntenter value of radius=");
scanf("%d",&r);

a= pi*r*r;
c=2*pi*r;

printf("tArea = %.2fn",a);
printf("tCircumference = %.2fn",c);

getch();

}

Output

calculate area and circumference of circle

 You can also perform this calculation by putting value 

C Code

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

void main()
{
int r;
float a, c;

printf("ntenter value of radius=");
scanf("%d",&r);

a= 3.14*r*r;
c=2*3.14*r;

printf("tArea = %.2fn",a);
printf("tCircumference = %.2fn",c);

getch();

}

Related Articles

Back to top button

Adblock Detected

Please turn off your Adblocker to view your content.