// Mr. Minich
// CMPSC 201
// Ch. 11 Demo Program #6
// January 20, 2000
// Purpose - to illustrate the use of a two-dimensional array.
#include <iostream>
using namespace std;
int findMax(int incArray[]);
int main()
{
int nums[5] = {0};
int sum = 0;
int i = 0;
ifstream infile;
infile.open("sequentialAccessFile.txt");
for (i = 0; i <= 5; i++)
{
infile >> nums[i];
sum = sum + nums[i];
}
cout << "The sum of the values read from the file is " << sum << endl;
cout << "The maximum value in the file is " << findMax(nums) << endl;
return 0;
}// end of main
int findMax(int incArray[])
{
int largest = incArray[0];
int i = 0;
for (i = 1; i <= 9; i++)
{
if (incArray[i] > largest)
{
largest = incArray[i];
}
}
return largest;
}// end of findMax