Question: Goals: Write a function that uses pass - by - reference. Share data between functions. Requirements: For this exercise, you will select statements to complete

Goals:
Write a function that uses pass-by-reference.
Share data between functions.
Requirements:
For this exercise, you will select statements to complete a program satisfying the following requirements:
Write a program that finds the area of a circle. To do so, include two functions:
getRadius()- This function has a single reference parameter. The function should ask the user for the radius of a circle and assign the value to it's reference parameter.
showArea()- This function accepts a single argument by value. It then calculates and displays the area of a circle.
The program should then call getRadius() followed by showArea(). The argument passed to getRadius then gets passed to showArea inside main. Include prototypes for both functions before the main function and the function definitions after main.
Here's the formula for the area of a circle: LaTeX: \pi r^2
#include
using namespace std;
[ Select ]
[ Select ]
showArea(
[ Select ]
);
int main()
{
[ Select ]
radius;
[ Select ]
[ Select ]
[ Select ]
[ Select ]
showArea(
[ Select ]
);
return 0;
}
[ Select ]
getRadius(double& r )
{
[ Select ]
[ Select ]
[ Select ]
}
[ Select ]
{
double area;
[ Select ]
cout << "The area of the circle is "<< area <<"."<< endl;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!