• In-Class Exercise Rectangle


    In class we built the rectangle function that computes the area of a rectangle. Here is the code:

    #include
    int main() {
      // set up width and length
      unsigned short width = 5, length;
      length = 10;
      // create an unsigned short initialized with
      // the result of width times length
      unsigned short area = width * length;
      std::cout << “Width: “ << width << std::endl;
      std::cout << “Length: “ << length << std::endl;
      std::cout << “Area: “ << area << std::endl;
      return 0;
    }

    In this assignment you are to extend this function to calculate the volume of a rectangular prism (length times width times height). You will need to make a new variable for the height, set it to some value and print it just like the other two variables. Then make a variable for the volume and assign to it the volume calculation and print it.