Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 / / Lab 9 - 1 . cpp circle calculations 2 / / Created / revised by on 3 4 #include 5 #include 6
Labcpp circle calculations Createdrevised by on #include #include using namespace std; function prototypes double getAreadouble rad; double getDiameterdouble rad; int main int choice ; double radius ; cout Circle area" endl; cout Circle diameter" endl; cout "Enter your choice or : ; cin choice; if choice choice cout "Invalid choice" endl; else cout "Radius: ; cin radius; if choice cout "Area: getArearadius; else cout "Diameter: getDiameterradius;end if cout endl;end if return ;end of main functionfunction definitions double getAreadouble rad const double PI ; double area ; area PI powrad; return area;end getArea function double getDiameterdouble rad return rad;end getDiameter functionFigure Code for Lab QUeStIONS Why are the statements on Lines and necessary? How else could you write the statement on Line If the program does not include the outer selection structure, what will the program display if the user enters the numbers and as the choice and radius, respectively? What are the scope and lifetime of the choice and radius variables? What are the scope and lifetime of the rad variable used in the getArea function? What are the scope and lifetime of the PI constant and the area variable? What scope and lifetime of the rad varible used in to get the diameter 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