/***************************************************************************************************************************************
Function 1: Call a function that will read in and return the radius
Function 2: Pass the radius to the circumference function and return the circumference to main.
Function 3: Pass the radius to the area function and return the area to main.
Main will now print the two answers.
Function 4: Pass the radius to the function, but this time, the function will calculate and return both the circumfernece and the area.
Main will once again print the circumference and the area.
****************************************************************************************************************************************/
//c=2(pi)r
#include <iostream>
#include <iomanip>
usingnamespace std;
double radius(double& r)
{
cout << "Enter a radius: ";
cin >> r;
return r;
}
double circ(double& c, double& r)
{
r = radius(r);
c = 2 * (3.14) * r;
return c;
}
double area(double& a, double& r)
{
r = radius(r);
a = 2 * 3.14 * r * r;
return a;
}
int main()
{
double c, r, a;
cout << fixed << setprecision(2);
cout << "Hi there!" << endl;
c = circ(c, r);
a = area(a, r);
cout << "The Circumference is: "<< c << endl;
cout << "The Area is: " << a << endl;
return 0;
}
// Function 2: Pass the radius to the circumference function and return the circumference to main.
This description implies, that the circ function should not get it's input from the user. It should only handle input passed to it as argument. This means circ should never call radius internally.
//Function 3: Pass the radius to the area function and return the area to main.
Exactly the same case.