The loop for collecting data would eliminate the need for all of those cin/cout statements:
1 2 3 4 5
|
for (int i = 0; i < 7; i++)
{
cout << "Enter value #" << i+1 << endl;
cin >> scores[i];
}
|
The loop for calculating and output would look like this:
1 2 3 4 5 6 7 8 9 10
|
double total = 0;
for (int j=0; j<7; j++)
{
cout << "Value #" << j+1 << " is " << scores[j] << ". Adding to total" << endl;
total += scores[j];
cout << "Current total is " << total << endl;
}
cout << "Final total is " << total << endl;
|
Hope that helps.
EDIT: As general programming practice, might I suggest defining a constant for the max array amount? Something like:
1 2 3 4 5 6 7 8 9 10
|
const int MAX_ARRAY = 7;
double scores[MAX_ARRAY]; // This would then be the array declaration
// And in loops, you'd use it like this
for (int i=0; i < MAX_ARRAY; i++)
{
. . .
}
|
Doing so means that if you ever need to change the size of that array, you just alter the constant, rather than every literal value of '7' in the code.
EDIT 2: The reason your code crashes is this:
for (int i = 7; i < 7; i + scores[i];
You're missing the closing brace. Even then, it's not going to do what you want because the increasing section of the loop is screwed.
Also, for your cout statement at the end, you indicate that it's a total of integers but you have an array of the other. In the interest of clarity, you should probably change one or the other.