# C++ Program to compute the area and circumference of a circle

Here, you will learn to find the area and circumference of a circle based on its radius entered by the user at run-time in C++ programming

## How to calculate the area and circumference of a circle based on its radius?

The area of a circle is the region occupied by the circle in a two-dimensional plane. It can be determined easily using a formula. area = πr2
The value of π is 3.14. And r indicates the radius of the circle. This formula can also be written as:
area = 3.14*r*r

The perimeter or circumference of a circle is its boundary or the complete arc length of the periphery of a circle
Perimeter of a circle = 2 π r = π D units
where,
•    r = radius of the circle
•    D = diameter of the circle.

## C++ program to find the area and circumference of a circle based on its radius

Ask the user to enter the value of the radius of the circle. Read the value to a variable r; Calculate the area using the formula given above
3.14 * r * r
Get the value to the variable area and display it on the screen.
Calculate the value of the perimeter of the circle
Get the value to the variable circum and display it on the screen.

### Algorithm

Step 1:  Call the header file `iostream`.

Step 2: Use the `namespace std`.

Step 3: Open the integer type main function; int main().

Step 4: Declare  float type variables r, area circum;

Step 5: Ask the user to enter the value of the radius of the circle.

Step 6: Get the value of radius to the variable r.

Step 7: Calculate the area using the formula 3.14 * r * r;

Step 8: Get the value to the variable area;

Step 9: Display the result;

Step 10: Calculate the circumference using the formula 2 * 3.14 * r;

Step 11: Get the value to the variable circum;

Step 12: Display the result;

Step 13: Exit

## C++ Source Code

```                                          ```#include<iostream>
using namespace std;
int main()
{
float r, area, circum;
cout<<"Enter the Radius of Circle: ";
cin>>r;
area = 3.14*r*r;
cout<<"\nArea of Circle = "<<area;
cout<<endl;
circum = 2*3.14*r;
cout<<"\nCircumference of Circle = "<<circum;
cout<<endl;
return 0;
}```
```

## OUTPUT

```Enter the Radius of Circle: 6
Area of Circle = 113.04

Circumference of Circle = 37.68
```
VIEW ALL
VIEW ALL
VIEW ALL