I would like to program that reads a file with 6 lines that have 7 numbers on each line. The output should save a file with sum, average, max and min of each line. For now I just have to figure out how to get the max and min numbers the robust way. For starters this is my code. (please note that my goal for now is just to sort my 7 entered numbers)
My code is not working and my total is wrong. Please advise.
//Program utilizing one file for input and one file for output
#include <iostream>
using namespace std;
int main()
{
int num1, num2, min = 0, max = 0, sum = 0, count = 0;
double avg;
cin >> num1 >> num2;
for (count = 0; count <= 7; count++)
{
if (num1 > num2) max = num1, min = num2;
if (num1 < num2) max = num2, min = num1;
else max = num1, min = num2;
sum = sum + min + max;
}
avg = sum/7.0;
cout << min << " & " << max << endl;
cout << "Sum = " << sum << endl;
cout << "Average = " << avg << endl;
system ("pause");
return 0;
}