Answered step by step
Verified Expert Solution
Question
1 Approved Answer
/ / 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started