#include <stdio.h>
#define PI 3.14159
float calculate_circle_area(float radius) {
float area = PI * radius * radius;
return area;
}
int main()
float area = PI * radius * radius;
return area;
}
int main()
{
float radius;
printf("Enter the radius of the circle: ");
scanf("%f", &radius);
float area = calculate_circle_area(radius);
printf("The area of the circle with radius %.2f is: %.2f\n", radius, area);
return 0;
}
float radius;
printf("Enter the radius of the circle: ");
scanf("%f", &radius);
float area = calculate_circle_area(radius);
printf("The area of the circle with radius %.2f is: %.2f\n", radius, area);
return 0;
}
Output:
Enter the radius of the circle: 5.5
The area of the circle with radius 5.50 is: 95.03
The calculate_circle_area function in this programme utilises the formula pi * radius2 to get the area after receiving the circle's radius as an input. 3.14159 is used to define the PI constant.
The user is invited to enter the circle's radius in the main function. Utilising scanf, the programme scans the input and saves it in the radius variable. Following that, it uses the specified radius to run the calculate_circle_area function and puts the outcome in the area variable. Finally, it uses printf to output the estimated area and radius.