CIS 150 C++ Spring 2017 Midterm exam #2 practice problem

Overview

Write a program to meet the listed requirements. Note: This includes more code than will be on the actual midterm #2.

Program requirements

  1. Write documentation comments. They must include the name of the program, the date, the course number, and your name.
  2. Use proper indentation throughout the program using four spaces per level of indent.
  3. Use spaces and NO tabs for the indentation.
  4. Write whatever include directives and using statements that your program needs.
  5. Write a function prototype for a function named writeToFile that takes a string filename and an integer length. It returns a Boolean value.
  6. Write a function prototype for a function named readFromFile that takes a string filename. It returns a Boolean value.
  7. Write a function prototype for a function named fillArray that takes an integer array and an integer length. It returns nothing.
  8. Write a function prototype for a function named displayArray that takes an integer array and an integer length. It returns nothing.
  9. Write a function prototype for a function named sumArray that takes an integer array and an integer length. It returns an integer.
  10. Write a function prototype for a function named writeArrayToFile that takes an ofstream reference, an integer array, and an integer length. It returns nothing.
  11. In main
  12. Write a function named writeToFile
  13. Write a function named readFromFile
  14. Write a function named fillArray
  15. Write a function named displayArray
  16. Write a function named sumArray
  17. Write a function named writeArrayToFile

Sample output run

    Basic file I/O test
    842 741 557 227 130 703 29 6 11 361 128 748
    Array and file I/O test
    495 24 382 129 154 490 95 114 231 261 392 37
    The sum of the array is 2804
    842 741 557 227 130 703 29 6 11 361 128 748 495 24 382 129 154 490 95 114 231 261 392 37