0 1 2 3 4
5 6 7 8 9
10 11 12 13.
My mission is to write a program that can read integers from user input files, display the data, and display the largest and smallest integers in the data set.
Please share the codes, thanks.
Here is what I have done so far
Code:
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
int main()
{
const int ARRAY_SIZE = 10;
int numbers[ARRAY_SIZE];
int count;
int small = INT_MAX;
int large = INT_MIN;
ifstream inputFile;
string GetFileName;
string line;
cout << "System >> Enter file to read: \n";
cout << "User >> ";
cin >> GetFileName;
for (count = 0; count < ARRAY_SIZE; count++)
inputFile >> numbers[count];
for (int count=0; count<10; count++)
{
if (numbers[count] < small)
small = numbers[count];
if (numbers[count] > large)
large = numbers[count];
}
cout << "The number are: ";
for (count = 0; count < ARRAY_SIZE; count++)
cout << " " << numbers[count] << endl;
cout <<"The smallest is: " << small << endl;
cout <<"The largest is: " << large << endl;
inputFile.close();
return 0;
}

