Calculate Area and Circumference of a Circle in C

This program reads the radius of a circle and calculates its area and circumference using basic arithmetic operators.

C Program

#include <stdio.h>

int main() {
    float radius, area, circumference;
    const float PI = 3.14159;

    printf("Enter the radius of the circle: ");
    scanf("%f", &radius);

    area = PI * radius * radius;
    circumference = 2 * PI * radius;

    printf("Area = %.2f\n", area);
    printf("Circumference = %.2f\n", circumference);

    return 0;
}

Explanation

  • The value of PI is declared as a constant using const float.
  • Area of a circle is calculated with the formula π × r².
  • Circumference is calculated with the formula 2 × π × r.
  • %.2f in printf rounds the output to 2 decimal places for cleaner display.

Sample Output

Enter the radius of the circle: 7
Area = 153.94
Circumference = 43.98

Leave a Comment