Skip to main content

8.6) Exercise 15


  1. Copy your solution to Exercise 11 or Exercise 12 (it doesn't matter which) to a new file. Add to this new program some code to display the contents of your vector or list, one element per line. Use a for loop and the appropriate const_iterator to do this. Check that your program compiles and runs successfully before proceeding any further.
  2. Add code that scales the values in your vector or list, multiplying each value by 0.5. Use a for loop and the appropriate iterator to do this.
  3. Add one for loop that displays the contents of your vector or list. You can just copy the code added in Step 1 for this. Compile and run your program to check that it behaves as expected.