// Mr. Minich
// CMPSC 101
// Ch. 10 Demo Program #8
// January 30, 2000
// Purpose - a linear search that finds the maximum value in a sequential access file. #include <iostream> #include <fstream>
using namespace std; int main() { int num = 0; int max = 0; int position = 1; int list[10]; int i = 0; ifstream infile; infile.open("numbers.txt"); for (i = 0; i <= 9; i++) { infile >> list[i]; } for (i = 0; i <= 9; i++) {
if (list[i] > max) { max = list[i]; } } cout << "The greatest integer is " << max << endl; return 0; }// end of main