C Program for Program to find the area of a circle?

The area is a quantity that represents the extent of the figure in two dimensions. The area of a circle is the area covered by the circle in a two-dimensional plane.

To find the area of a circle, the radius [r] or diameter [d] (2 × radius) is required. The formula used to calculate the area is (π × r2) or {(π × d2)/4}.

Syntax

area = ? × radius × radius
area = (? × diameter × diameter) / 4

Method 1: Finding Area Using Radius

This method calculates the circle area using the radius value −

#include <stdio.h>

int main() {
    float pi = 3.14159;
    float radius = 6.0;
    float area;
    
    printf("The radius of the circle is %.2f<br>", radius);
    area = pi * radius * radius;
    printf("The area of the given circle is %.2f<br>", area);
    
    return 0;
}
The radius of the circle is 6.00
The area of the given circle is 113.09

Method 2: Using Math Library with pow() Function

This approach uses the pow() function from math.h library to calculate the square of the radius −

#include <stdio.h>
#include <math.h>

int main() {
    float pi = 3.14159;
    float radius = 6.0;
    float area;
    
    printf("The radius of the circle is %.2f<br>", radius);
    area = pi * pow(radius, 2);
    printf("The area of the given circle is %.2f<br>", area);
    
    return 0;
}
The radius of the circle is 6.00
The area of the given circle is 113.09

Method 3: Finding Area Using Diameter

When diameter is given instead of radius, we can use the formula (π × d2)/4 −

#include <stdio.h>

int main() {
    float pi = 3.14159;
    float diameter = 12.0;
    float area;
    
    printf("The diameter of the circle is %.2f<br>", diameter);
    area = (pi * diameter * diameter) / 4;
    printf("The area of the given circle is %.2f<br>", area);
    
    return 0;
}
The diameter of the circle is 12.00
The area of the given circle is 113.09

Key Points

  • Use float or double for precise calculations involving decimal values.
  • The value of π (pi) can be approximated as 3.14159 for better accuracy.
  • Both radius and diameter methods produce the same result when diameter = 2 × radius.

Conclusion

Calculating the area of a circle in C is straightforward using the standard formula πr2. Choose the appropriate method based on whether you have the radius or diameter as input.

Updated on: 2026-03-15T10:48:02+05:30

17K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements