Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the following code fragment. Assume that the variables width, length an

ID: 3812034 • Letter: C

Question

Consider the following code fragment. Assume that the variables width, length and area have all been declared and initialized (if necessary).

// compute the area of the building lot in acres
computeLotInAcres(width, length, area);

// Display results
cout << "A building lot of "
<< width << " feet by "
<< length << " feet has "
<< area << " acres. ";

What must be true about the area argument to the computeLotInAcres() function?

a. It is passed as a reference parameter.

b. It is a defined constant.

c. It must be declared in the computerLotInAcres() function, but not in main()

d. It is passed as a constant reference parameter.

Explanation / Answer

Answer: a. It is passed as a reference parameter.

area argument must be a parameter by reference. Because we are calculating the area in the function and not returning the value so the value calculated for area in fucntion should reflect in main method. So we have pass the area as a parameter by reference so the area value can be reflected in main.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote