Question: / / Lab 1 0 - 1 . cpp - circle calculations / / Created / revised by on #include #include using namespace std; /
Labcpp circle calculations
Createdrevised by on
#include
#include
using namespace std;
function prototypes
void displayChoices;
void getAreadouble rad, double &area;
void getDiameterdouble rad, double &diameter;
int main
int choice ;
double radius ;
double circleArea ;
double circleDiameter ;
displayChoices;
cout "Enter your choice or : ;
cin choice;
if choice choice
cout "Invalid choice" endl;
else
cout "Radius: ;
cin radius;
if choice
getArearadius circleArea;
cout "Area: circleArea;
else
getDiameterradius circleDiameter;
cout "Diameter: circleDiameter;
end if
cout endl;
end if
return ;
end of main function
function definitions
void displayChoices
cout Circle area" endl;
cout Circle diameter" endl;
end displayChoices
void getAreadouble rad, double &area
const double PI ;
area PI powrad;
end getArea function
void getDiameterdouble rad, double &diameter
diameter rad;
end getDiameter function
QUeStIoNS The main function passes two variables to the getArea function. Which lines in the program indicate whether the variables are passed by value or by reference?
Why is the radius variable passed by value? Why are the circleArea and circleDiameter variables passed by reference?
Why is the displayChoices function a void function?
How do the getArea and getDiameter functions, which are void functions, send information back to the main function?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
