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

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!