Question: Lab 5 : Writing Functions that call other functions. Passing parameter By - Reference Objective The objective of this lab is to call functions from

Lab 5: Writing Functions that call other functions. Passing parameter By-Reference
Objective
The objective of this lab is to call functions from within other functions and passing parameters by-reference. Additionally, you will practice writing proper preconditions and postconditions.
Requirements
Write a program that calculates the area of a rectangle. The program should have three functions: getLength, getWidth, and calculateArea.
Write adequate preconditions and postconditions comments for all functions.
The functions prototypes must be declared above the main function and the definitions must be placed below the main function.
getLength and getWidth functions do not take any arguments and return double values.
The calculateArea function takes two parameters by-reference named length and width and returns the calculated area as double.
The getLength and getWidth functions should ask the user for the length and width of the rectangle, respectively, and return their values. The calculateArea function should get the length and width values as arguments, calculating and returning the area.
The main function should call the getLength, getWidth, and calculateArea functions, and printing the result to the console.
Example Output
Lab 5: Writing Functions that call other functions. Passing parameter By-Reference
Objective
The objective of this lab is to call functions from within other functions and passing parameters byreference. Additionally, you will practice writing proper preconditions and postconditions.
Requirements
- Write a program that calculates the area of a rectangle. The program should have three functions: getLength, getWidth, and calculateArea.
- Write adequate preconditions and postconditions comments for all functions.
- The functions' prototypes must be declared above the main function and the definitions must be placed below the main function.
- getlength and getWidth functions do not take any arguments and return double values.
- The calculateArea function takes two parameters by-reference named length and width and returns the calculated area as double.
- The getLength and getWidth functions should ask the user for the length and width of the rectangle, respectively, and return their values. The calculateArea function should get the length and width values as arguments, calculating and returning the area.
- The main function should call the getLength, getWidth, and calculateArea functions, and printing the result to the console.
Example Output
Enter the length of the rectangle: 2.23
Enter the width of the rectangle: 5.15
The area of the rectangle is: 11.4845
Lab 5 : Writing Functions that call other

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 Programming Questions!