Area of Circle
#include <stdio.h>
#include <math.h>
int main() {
double radius, area;
printf("Enter the radius of the circle: ");
scanf("%lf", &radius);
if (radius >= 0) {
area = M_PI * radius * radius; // M_PI is a constant for the value of π
printf("The area of the circle with radius %.2lf is %.2lf\n", radius, area);
} else {
printf("Invalid radius. Please enter a non-negative value.\n");
}
return 0;
}
Comments
Post a Comment