C Program for Program to find the area of a circle?

CServer Side ProgrammingProgramming

The area is a quantity that represents the extent of the figure in two dimensions. The area of a circle is the area covered by the circle in a two dimensional plane.

To find the area of a circle, the radius[r] or diameter[d](2* radius) is required.

The formula used to calculate the area is (π*r2) or {(π*d2)/4}.

Example Code

To find the area of a circle using radius.

Live Demo

#include <stdio.h>
int main(void) {
float pie = 3.14;
printf("The area of the given circle is %f", area);
return 0;
}

Output

The radius of the circle is 6
The area of the given circle is 113.040001

Example Code

To find the area of a circle using radius using math.h library. It uses the pow function of the math class to find the square of the given number.

Live Demo

#include <stdio.h>
int main(void) {
float pie = 3.14;
printf("The area of the given circle is %f", area);
return 0;
}

Output

The radius of the circle is 6
The area of the given circle is 113.040001

Example Code

To find the area of a circle using Diameter.

Live Demo

#include <stdio.h>
int main(void) {
float pie = 3.14;
int Diameter = 12;
printf("The Diameter of the circle is %d \n" , Diameter);
float area = (float)((pie* Diameter * Diameter)/4);
printf("The area of the given circle is %f", area);
return 0;
}

Output

The Diameter of the circle is 12
The area of the given circle is 113.040001
Published on 15-Jul-2019 12:04:40