//--------------------------------------------------------------------
// fileio1.cpp
//--------------------------------------------------------------------

// Reads five integer values from the file values.dat and displays // their sum on the screen.
#include <iostream.h> // For cin, cout #include <fstream.h> // For file input/output
void main() { ifstream inFile("values.dat"); // Open input file values.dat int num, // Number read from file sum = 0; // Sum of numbers read in
// Read in numbers and compute their sum. for ( int j = 0 ; j < 5 ; j++ ) { inFile >> num; sum += num; }
// Output the sum. cout << "Sum = " << sum << endl;
// Close the input file stream. inFile.close(); }