- C++ program to find factorial using recursive function
- C++ program to convert binary number to decimal and decimal to binary
- C++ program to display prime numbers between two intervals
- C++ program to print Pascal’s and Floyd’s triangle
- C++ program to print star pyramid patterns
- C++ Hello World Program
- C++ program to display Fibonacci series using loop and recursion
- C++ program to find area of the circle
- C++ program to calculate the area of the square with and without using function
- C++ program to encrypt and decrypt the string
- C++ program to convert temperature
- C++ program to check prime number
- C++ program to check palindrome number
- C++ program to make simple calculator using switch case
- C++ program for time conversion (convert time format)
- C++ program to find GCD or HCF
- C++ program to check for the power of two
- C++ program to check Armstrong number
- C++ program to check leap year
- C++ program to find LCM of two numbers

In this example, you will learn about C++ program to find area of the circle with and without using the function.

Formula to find area of the circle:

Area_circle = Π * r * r

**where,**

mathematical value of Π is 3.14159.

Let’s calculate the are of the circle using two methods.

```
//C++ program to calculate area of the circle
#include <iostream>
using namespace std;
int main() {
float radius, area_circle;
// take radius as input
cout << "Enter the radius of circle: ";
cin >> radius;
area_circle = 3.14 * radius * radius;
cout << "Area of circle: " << area_circle << endl;
return 0;
}
```

**Output**

Enter the radius of circle: 5 Area of circle: 78.5

```
//C++ program to find area of the circle using function
#include <iostream>
using namespace std;
//function declaration
float areaOfCircle(float radius_circle);
int main() {
float radius;
// take radius as input
cout << "Enter the radius of circle: ";
cin >> radius;
cout << "Area of circle: " << areaOfCircle(radius) << endl;
return 0;
}
// function definition to calculate area of circle
float areaOfCircle(float radius_circle)
{
float area_circle;
area_circle = 3.14 * radius_circle * radius_circle;
return area_circle; //return area
}
```

**Output**

**Explanation**

In the first program, we have simply calculated area of the circle in the main program.

However, we have used `areaOfCircle( )`

function for calculating area of the circle in the second program.