cin and Computation Worksheet

  1. Write the statements to calculate the area and perimeter of a room. Your statements should read in the length and the width of the room, calculate the perimeter, calculate the area, and then print the length, width, perimeter, and area.
  2. Write the statements to declare the variables you used in the previous problem.
  3. Change your statements for problem 1 so that you read in the length and width of the room, print the length and width, calculate the perimeter, print the perimeter, calculate the area, and print the area.
  4. Will your program in problem 3 work correctly?
  5. What if you change your program in problem 3 so that it calculates the area and perimeter first, before it reads in the length and the width? Will this version of the program work correctly?
  6. What are the values of the variables length and width before the cin statement is executed?

Email Me | Office Hours | My Home Page | Department Home | MCC Home Page

© Copyright Emmi Schatz 2002