You're online now.

Hurray! you are online now.

# Write a C program to calculate the area of circle

``````// Write a c program to calculate the area of circle.
#include<stdio.h>
int main(){
float pi = 3.14, radius, area;
printf("Enter the radius of the circle : ");
printf("Area : %f", area);
return 0;
}``````

In the above program calculate the area of circle given the radius from the user using the scanf() function. And after calculate the area then display the output on the terminal.

``#include<stdio.h>``

This line includes the library of stdio.h which helps to input/output in the program.

``int main(){``

It is the entry point of the program. Every program starts from the main() function.

``float pi = 3.14, radius, area;``

Declares the three variables as float named pi, radius andd area. pi is set by the value of 3.14 is the constant. radius is store the radius variable which the value of entered by the user. area stored the value of the calcualated area of circle.

``printf("Enter the radius of the circle : ");``

Prompt to the user to enter the radius of the circle using the printf() function.

``scanf("%f", &radius);``

Reads the value from the user and store into the radius variable using the scanf() function. Here we use the “%f” format specifier because we deal with the floating point value.

``area = pi * radius * radius;``

This is the formula to calculate the area of the circle. We all know the formula of the circle that (π*r2).

``printf("Area : %f", area);``

Displayed area of the circle using the printf().

``````	return 0;
}``````

Execute the program successfully and return 0.

## Algorithm

1. Start
2. Declares and assigned three variables as float pi = 3.14, radius and area.
3. Display “Enter  the radius of the circle”.