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

Problem 3a: (8 points) Write a C++ program that inputs the length, width, & heig

ID: 3879295 • Letter: P

Question

Problem 3a: (8 points) Write a C++ program that inputs the length, width, & height (in integers) of a house. Write a function that uses Call-By-Reference void rect (int& ar, int& v, int len, int wid, int hgt) that computes the area ar and the volume vl of the house Enter your name as a Global variable and all other variables should be local variables in main o rrect. Volume= length * width * height Sample Input Length of House (ft): 50 Width of House (ft): 60 Height of House (ft):20 Sample Output (Your name will replace mine) Cindy has a house with 3000 square feet that contains 60000 cubic feet Problem 3b: (7 points) Draw the memory and run-time stack when rect is called. This should look similar to Fig 2.21c in the textbook and ALL of your variable names should be shown including name. Remember, local variables are stored on the stack and pointers will have arrows. You may hand draw & scan or use Paint or Visio or Googledraw, etc to create this and paste into your document

Explanation / Answer

#include <iostream>
using namespace std;

// declaring NAME as a global variable
string NAME = "Nash"; // Put your name here

void rect(int &ar, int&vl, int len, int wid, int hgt)
{
// calculating area and length
ar = len*wid;
vl = len*wid*hgt;
}

main() {
int l, w, h, area, volume;
  
// taking user input
cout << "Length of House (ft): ";
cin >> l;
cout << "Width of House (ft): ";
cin >> w;
cout << "Height of House (ft): ";
cin >> h;
  
// calling function
rect(area, volume, l, w, h);
  
// printing output
cout << NAME << " has a house with " << area << " square feet that contains " << volume << " cubic feet";
}

/* SAMPLE OUTPUT
Length of House (ft): 50
Width of House (ft): 60
Height of House (ft): 20
Nash has a house with 3000 square feet that contains 60000 cubic feet
*/

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