C Program to Find Area and Circumference of a Circle

This program calculates the area and circumference of a circle using the formulas πr² and 2πr. The value of π is defined as a constant using the #define preprocessor directive.

Concept Overview

The area and circumference of a circle can be calculated using simple mathematical formulas: Area = π × r² and Circumference = 2 × π × r. In C, we can define π as a constant and perform these calculations easily.

Program

// Code file not found: #include <stdio.h>
#define pi 3.1415
int main()
{
    int r = 5;
    float area, circum;
    area = pi * r * r;
    circum = 2 * pi * r;
    printf("Area of circle is %f\n", area);
    printf("Circum of circle is %f", circum);
}

Output

Area of circle is 78.537498
Circum of circle is 31.415001

Explanation