C Program to calculate area and circumference of circle

0
2
digitalample eye

Write a program to calculate area and circumference of a circle where radius of a circle is imputed and define pi as constant.

Write a c program to calculate area and circumference of the circle.

C Code

#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();

}

LEAVE A REPLY

Please enter your comment!
Please enter your name here