Error assistance

I am getting an error message on this and I need some help identifing how to correct it.
(32) : error C2065: 'i' : undeclared identifier
(33) : error C2065: 'i' : undeclared identifier



#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
const int MAX_ITEMS = 10;
float x[MAX_ITEMS];
float average;
float sum;
float max, min;

// Enter data.
cout << "Enter " << MAX_ITEMS << " numbers: ";
for (int i = 0; i < MAX_ITEMS; i++)
cin >> x[i];

// Compute the average value.
sum = 0.0;
for (int i = 0; i < MAX_ITEMS; i++)
sum+= x[i];
average = sum / MAX_ITEMS;

// define max, min variables
max = x[0];
min = x[0];

// search the array for max, min

for(int i = 0; i < MAX_ITEMS; ++i)
{
if(x[i] < min)
min = x[i];
if(x[i] > max)
max = x[i];
}

system ("cls");



// Displays the diference between each item and the average.

cout << fixed << showpoint << setprecision (2) << endl;
cout << setw(4) << " Value " << setw(8) << "Percent of Total"
<< endl;
for (int i= 0; i < MAX_ITEMS; i++)
cout << setw(4) << x[i] << setw(8)
<< setw(14) << (x[i] / sum) << endl << endl;

cout << "Values used range from " << min << "to" << max << endl << endl;
cout << " The average of the Ten values = " << average << endl << endl;
cout << "\\nItems in the array that are larger than the average: "
for (int i = 0; i < MAX_ITEMS; i++)
{
if (x[i] > average)
}
cout << x[i] << setw(8) <<endl;

system ("pause");
return (0);

}
If I'm reading your code correctly...the errors are on these lines:

1
2
if(x[i] < min)
min = x[i];


Which doesn't make sense to me...since the following two lines don't have that error...
It made no sense to me either, until I copied it out of the VB C++ and pasted it into the DEV c++ compiler. It showed me another error above these error the corrected itself when I fixed the error above these lines. Thank You very much for your efforts to help me learn.
I have complted the work and it is now working fine with one acception. The output for the larger than average only output one number, where it should output all of the number oabve the average of the array. I could use some help on this if possible.
In the code you have posted above:
1
2
3
4
5
6
7
8
9
cout << "Values used range from " << min << "to" << max << endl << endl;
cout << " The average of the Ten values = " << average << endl << endl;
cout << "\\nItems in the array that are larger than the average: " ; //semi colon missing
for (int i = 0; i < MAX_ITEMS; i++)
{
if (x[i] > average)
cout << x[i] << setw(8) <<endl; //This line should be here inside the loop
}
//cout << x[i] << setw(8) <<endl; //NOT here 
I would like to say, that the helpful tips that I am getting know are helping me to understand C++ much more now. I Thank You Much for your comments. I have corrected all the suggestions and it works, compiling and outputing properly now.
Topic archived. No new replies allowed.