Question: 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

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!