In this article we will show you, 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.

## Area Of a Circle

The area of a circle is number of square units inside the circle. 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 formula: A=πr² (Here A is the area of the circle and r is radius). In this C program, we allow user to enter radius, and then finds area, and circumference

/* 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; }

**ANALYSIS: **We defined pi as global variable and assigned value as 3.14. This program allows user to enter the value of a radius and then it will calculate the area of circle as per the formula.

**OUTPUT**

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

Distance around the circle is called as circumference. If you know the circumference then we can calculate the area of a circle using 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; }

**ANALYSIS: **We included one more header file called <math.h>, it will allow to use pi without declaring it. This program allows user to enter the value of a circumference and then it will calculate the area of circle as per the formula.

**OUTPUT**

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

Distance across the circle passing through the center is called as diameter. If we know the diameter then we can calculate the area of a circle using 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: **

We defined pi as local float variable and assigned value as 3.14. This program allows user to enter the value of a diameter and then it will calculate the area of circle as per the formula we shown above.

We also mentioned other approach.

diameter = 2 * radius

radius = diameter/2

area = π*radius*radius

**OUTPUT**

Thank You for Visiting Our Blog