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
Make the following changes to the program so that the values will be returned from the function.
Change the return type for the computerectangle function from void to double both in prototype and definition header
Change the call to:
o diagonal, perimeter, area computerectangle height width;
Add a return at the end of the computerectangle 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.
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.
Should the height and width parameters be call by value or call by reference? Explain your answer.
Change all instances of the variable perimeter to p in the computerectangle 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
