CS110 Lab #4 In-lab Exercise:

Objectives

Exercise #1

  • Get a copy of the string_exe2.cpp file by:

    The purpose of the program is to practice how to use length(), find() and substr() funcitons.

  • Add the 2 lines of code in the appropriate place.
  • Compile and run this C++ program.
  • Show your lab instructor the program output.

    Exercise #2

  • Get a copy of the iodemo.cpp file by:
  • This program demonstrates how to use File I/O.
  • It will read four floating point values from the input data fileData.In and output these numbers to an output file Data.Out in reverse order.
  • Create the input data file Data.In.
  • If you are not sure how to do this, make sure to go back to the File Input and Output section.
  • Compile and run this program.
  • Modify the program so it also outputs the average of the four input numbers.
  • View the output file by using cat Data.Out.
  • Show your lab instructor the output file Data.Out
    CS Dept Home Page CS Dept Class Files CS110 Class Files
    Copyright: Department of Computer Science, University of Regina.