Write a C++ program that takes in the radius (as in integer) of a circle from user and calculate the area of the circle through a function. If the area is greater than 50, display the circle’s area along with a message that the circle is big else display the circle’s area and the message that the circle is small. Define a function named calculateArea() to take in the radius as its argument and calculate the circle’s area before returning the area as type double.
#include <iostream>
#include <cmath>
using namespace std;
double calculateArea(double);
int main(int argc, char** argv)
{
double radius;
do
{
cout << "Input the value of radius: ";
cin >> radius;
}
while(radius <= 0);
double area = calculateArea(radius);
if(area > 50)
cout << area << endl << "The circle is big." << endl;
else
cout << area << endl << "The circle is small." << endl;
return 0;
}
double calculateArea(double radius)
{
return M_PI * pow(radius, 2) / 2.0;
}