I am a C++ newbie and trying to write a program that will receive 8 integers from a user. The integers will be separated by spaces. The program will then display the integers in reverse order.
I also need to derive the average of the input integers
In the output of the code below, I am asked for the integers and enter them, but I don't think the values are being received. The "sum" results in the value of 131 no matter what integers I use.
Any help would be greatly appreciated. Sorry about not using tags.
using namespace std;
int ave, sum;
cout << "Please enter 8 positive integers:";
for (i = 0; i < 8; i++ )
cin >> list[i];
cout << endl << "The values in reverse order are:" << endl;
for (i = 7; i >= 0; i--)
sum += list[i];
cout << list[i] << " ";
ave = sum/8;
cout << "The average is " << sum << "/8 " << "= " << ave;