By | 25.12.2016

# Calculate Area of Circle using Function

Write a C++ Program to Calculate Area of Circle using Function. Here’s simple C++ Program to Calculate Area of Circle using Function in C++ Programming Language.

## Numbers in C++

Normally, when we work with Numbers, we use primitive data types such as int, short, long, float and double, etc. The number data types, their possible values and number ranges have been explained while discussing C++ Data Types.

Here is source code of the C++ Program to Calculate Area of Circle using Function. The C++ program is successfully compiled and run(on Codeblocks) on a Windows system. The program output is also shown in below.

### SOURCE CODE : :

```/*  C++ Program to Calculate Area of Circle using Function  */

#include <iostream>
#define PI 3.14159
using namespace std;

float AreaWithDiameter(float diameter);

int main()
{
char choice='0';
cout<<"\n\t\t\tFind Area Of Circle:"<<endl;

for(;choice!='1'&&choice!='2';)
{
cout<<"2 to Enter Diameter ";
cin>>choice;
if(choice!='1'&&choice!='2')
cout<<"\nEnter a VALID Option ";

}

if(choice=='1')
{
cout <<"\nEnter Radius To Find Area: ";
}
else if(choice=='2')
{
cout <<"\nEnter Diameter To Find Area: ";
cin>>diameter;
circleArea=AreaWithDiameter(diameter);

}
cout<<"\nArea of Circle is:->> "<<circleArea<<endl;
return 0;
}

{

}

float AreaWithDiameter(float diameter)
{

return (AreaOfCircle(diameter/2));
}```

### OUTPUT : :

```/*  C++ Program to Calculate Area of Circle using Function  */

Find Area Of Circle:

2 to Enter Diameter

Enter Radius To Find Area: 4

Area of Circle is:->> 50.2654

Process returned 0```

Above is the source code for C++ Program to Calculate Area of Circle using Function which is successfully compiled and run on Windows System.The Output of the program is shown above .

If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section.We will try our best to reach up to you in short interval.

Article Rating
Category: C++ Programming Number Programs Tags: My name is Tunde Ajetomobi, a Tech Enthusiast and Growth Hacker. I enjoy creating helpful content that solves problem across different topics. Codezclub is my way of helping young aspiring programmers and students to hone their skills and find solutions on fundamental programming languages.

Subscribe
Notify of Inline Feedbacks kindly assist with this question
write a program to compute the area and circumference of a circle also analyse the program The area of circle is ( PI*r*r )and circumference is ( 2*PI*r ).
You can create a function which will return area and another function with return value 2*PI*r. That’s all !  