Write a C Program to find the area and circumference of a circle.
The program simply calculates the area and circumference of a circle using its formula. Although the value PI is already defined with preprocessor directives. It takes that value if PI is used anywhere in the program.
You can check out the following if you do not know about the operators as this program uses operators.
C Program to Calculate the Area and Circumference of a Circle
//Find the area and circumference of a circle
//Defining the pi value
#define PI 3.142857
float area, circum;
printf("Enter the radius of a circle: ");
//calculate the area
area = PI * r * r;
printf("Area of a circle: %f ", area);
//calculate the circumference
circum = 2 *PI * r;
printf("\n Circumference of a circle: %f ", circum);
The output of calculating the area and circumference of a circle in C.
Enter the radius of a circle: 5
Area of a circle: 78.571426
Circumference of a circle: 31.428570