robert
public text v1 · immutable//Robert Griesmeyer
//chapter7_6
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
int main()
{
int length;
ifstream inFile;
int numbere[20];
char file[15];
int highest;
int lowest;
int total;
double average;
cout << "What is the file name that is to be read? ";
cin >> file;
cout << "The file can only be 15 characters of size and below.";
inFile.open(file);
cout <<"Reading the contents of the file...\n\n";
if(!file) //test for errors
cout << "Error opening the file.";
for(int i = 0; i < length; i++)
{
inFile >> numbers[i];
cout << numbers[i] << endl;
}
highest = numbers[0];
for(int i = 1; i < length; i++)
if(numbers[i] > highest)
{
highest = numbers[i];
}
lowest = numbers[0];
for(int i = 1; i < length; i++)
if(numbers[i] < lowest)
{
lowest = numbers[i]; \
}
for(int i = 0; i < length; i++)
{
total += numbers[i];
}
return 0;
}