Calculating Circumference and Area of a Circle in C
In this blog post, we'll explore a simple C program that calculates the circumference and area of a circle based on the provided radius. Let's take a look at the C code:
#include <stdio.h>
int main() {
const double PI = 3.14159;
double radius;
double circumference;
double area;
printf("\nEnter radius of a circle :");
scanf("%lf", &radius);
circumference = 2 * PI * radius;
area = PI * radius * radius;
printf("Circumference: %lf\n", circumference);
printf("Area: %lf\n", area);
return 0;
}
Copy and paste this C code into your favorite compiler, and you'll be able to calculate the circumference and area of a circle by providing the radius.
Feel free to modify and experiment with the code to enhance your understanding of C programming. Happy coding!