Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2 . Make the following changes to the program so that the values will be returned from the function. Change the return type for the

2. Make the following changes to the program so that the values will be returned from the function.
Change the return type for the compute_rectangle function from void to double (both in prototype and definition header)
Change the call to:
o diagonal, perimeter, area = compute_rectangle (height, width);
Add a return at the end of the compute_rectangle function
o return diagonal, perimeter, area;
Run your program. What is output by the program for each result?
Why will this strategy never work for this function?
Undo the above changes made in the program.
3. Add call by reference parameters to send back the values of area, perimeter and diagonal to main. Change the prototype, function call and function definition to get the program to compile and run correctly.
4. Should the height and width parameters be call by value or call by reference? Explain your answer.
5. Change all instances of the variable perimeter to p in the compute_rectangle function (including the prototype and header line). Run your program. What does this tell you about the agreement of names of call by reference parameters in main and in the function?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

1. Define the nature of interviews

Answered: 1 week ago

Question

2. Outline the different types of interviews

Answered: 1 week ago