Answer to Question #1598 in C++ for idaira

Question #1598
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.
1
Expert's answer
2011-02-18T06:14:11-0500
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS