In this example, the user is asked to enter a number for radius. The program will then use the enetered radius to calculate the area of a circle.

#include <stdio.h> int main() { double r, res; printf("Enter the radius: "); scanf("%lf", &r); res = 3.14 * r * r; printf("Area of the circle is: %.2lf\n", res); return 0; }

## Formula to Calculate Area of a Circle

The formula to calculate area of a circle is as following,

3.14 (value of PI) * radius * radius

First, two variables are declared of type double, namely ** r** and

**. The variable**

*res***will store the value of**

*r***as an input in it. The variable**

*radius***will store the end result. The program will then use the above mentioned formula to calculate the area of a circle. The result will then be stored in res. Eventually, it is displayed on the console.**

*res*## Output

Enter the radius: 5 Area of the circle is: 78.50