Question
A C++ Program = Modularizing a Program with void Functions Step 1: Modularize the program by adding the following 4 functions. None of them have
A C++ Program = Modularizing a Program with void Functions
Step 1: Modularize the program by adding the following 4 functions. None of them have any parameters.
void displayMenu()
void findSquareArea()
void findCircleArea()
void findTriangleArea()
To do that you will need to carry out the following steps:
Write prototypes for the four functions and place them above main.
Write function definitions (consisting of a function header and initially empty body) for the four functions and place them below main.
Move the appropriate code out of main and into the body of each function.
Move variable definitions in main for variables no longer in main to whatever functions now use those variables. They will be local variables in those functions. For example, findSquareArea will need to define the side variable and findCircleArea will need to define the radius variable. All of the functions that compute areas will now need to define a variable named area.
Move the definition for the named constant PI out of main and place it above the main function.
In main, replace each block of removed code with a function call to the function now containing that block of code.
Step 2: Compile the code, Make sure it runs correctly for all menu choices.
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