How to write C Program to Calculate Area Of a Circle with example?. Before we step into the program, Let see the definitions and formulas behind the Area Of a Circle. The area of a circle is the number of square units inside the circle. The standard formula to calculate the area of a circle is A=πr².

## C Program to Calculate Area Of a Circle using Radius

If we know the radius, then we can calculate the area of a circle using the formula: A=πr² (Here A is the area of the circle and r is radius).

In this C program, we allow the user to enter the radius, and We defined pi as a global variable and assigned value as 3.14. Next, this C program will find the area of the circle and circumference of a circle as per the formula.

/* C Program to Calculate Area Of a Circle using Radius */ #include<stdio.h> #define PI 3.14 main() { float radius, area, circumference; printf("\n Please Enter the radius of a circle\n"); scanf("%f",&radius); area = PI*radius*radius; circumference = 2* PI*radius; printf("\n Area Of a Circle = %.2f\n", area); printf("\n Circumference Of a Circle = %.2f\n", circumference); return 0; }

**OUTPUT**

## C Program to Calculate Area Of a Circle using Circumference

Distance around the circle called the circumference. If you know the circumference, we can calculate the area of a circle using the formula: A= C²⁄ 4π (Here C is circumference)

/* C Program to Calculate Area Of a Circle using Circumference */ #include <stdio.h> #include <math.h> main() { float area, circumference; printf("\n Please Enter the Circumference of a circle \n"); scanf(" %f ", &circumference); /* We can use M_PI instead of defining PI by adding math.h header file */ area = (circumference * circumference) /(4* M_PI); printf("\n Area Of Circle = %.2f\n", area); return 0; }

Here, we included one more header file called <math.h>, It allows using pi without declaring it. This program allows the user to enter the value of circumference. Then it will calculate the area of a circle as per the formula.

### C Program to Calculate Area Of a Circle using Diameter

The distance across the circle passing through the center, called as diameter. If we know the diameter, we can calculate the area of a circle using the formula: A=π/4*D² (D is the diameter)

/* C Program to Calculate Area Of a Circle using Diameter */ #include<stdio.h> main() { float PI = 3.14; float area1, area2, diameter, radius; printf("\nPlease Enter the Diameter of a circle\n"); scanf("%f", &diameter); area1 = (PI/4)* (diameter*diameter); //diameter = 2 * radius //radius = diameter/2 radius = diameter/2; area2 = PI*radius*radius; printf("\nArea of Circle using direct formula = %.2f\n", area1); printf("\nArea of Circle Using Method 2 = %.2f\n", area2); return 0; }

**ANALYSIS**

This program allows the user to insert the value of the diameter. Then it calculates the area of a circle as per the formula we shown above.

We also mentioned other approaches.

diameter = 2 * radius

radius = diameter/2

area = π*radius*radius

**OUTPUT**