This C Program calculates the area of a Circle given it’s radius. The formula to calculate the area is: Area = π × r2 where r is the radius of the circle & π value is 22/7.
Here is source code of the C program to calculate the area of a circle. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
* C program to find the area of a circle, given the radius
#define PI 3.142
float radius, area;
printf("Enter the radius of a circle \n");
area = PI * pow(radius, 2);
printf("Area of a circle = %5.2f\n", area);
$ cc pgm2.c -lm $ a.out Enter the radius of a circle 30 Area of a circle = 2827.80
Sanfoundry Global Education & Learning Series – 1000 C Programs.