0

i dont know why im getting a compling error for this...

error is:

line 112 - name lookup of `i' changed for new ISO `for' scoping

line 95 - using obsolete binding at `i'

what does that even mean?!

my current code is below, to get a better understanding.

is this a common error? i had this error before, but a simple semi-colon fixed my issues before. but not this one and im all out of ideas.

```
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
const int nScores = 6;
// function to sort scores
int compare(const void*pa, const void* pb)
{
const int& a = *static_cast<const int*>(pa);
const int& b = *static_cast<const int*>(pb);
if (a < b) return -1;
if (a > b) return 1;
return 0;
}
// function to average scores
double getAverage(int* score, int n)
{
int sum = 0;
int i = 0;
for (i = 0; i < n; i++)
sum += score[i];
double average = double(sum) / n;
return average;
}
// function to find A-scores
int AScoreGreater(int* score, int x)
{
int nGreater = 0;
int i;
for (i = 0; i < nScores; i++)
if (score[i] >= 90) nGreater++;
return nGreater;
}
// function to find B-scores
int BScoreGreater(int* score, int x)
{
int nGreater = 0;
int i;
for (i = 0; i < nScores; i++)
if (score[i] >= 80) nGreater++;
return nGreater;
}
// function to find C-scores
int CScoreGreater(int* score, int x)
{
int nGreater = 0;
int i;
for (i = 0; i < nScores; i++)
if (score[i] >= 70) nGreater++;
return nGreater;
}
// function to find PASSING-scores
int ABCScoreGreater(int* score, int x)
{
int nGreater = 0;
int i;
for (i = 0; i < nScores; i++)
if (score[i] >= 70) nGreater++;
return nGreater;
}
// main hub for all
int main()
{
// create an empty list
const int MAX_SCORES = 6;
int nScores = 0;
int score[MAX_SCORES];
// prompt for how many students
cout << "How many records would you like to view? ";
cin >> nScores;
cin.ignore(1000, 10);
cout << " " << endl;
// read and save the records
for (int i = 1; i < nScores; i++)
{
if (nScores < MAX_SCORES)
{
// create a record and read it from file
cout << "Enter score: ";
cin >> nScores;
cin.ignore(1000, 10);
cout << " " << endl;
}
}
qsort (score, nScores, sizeof(int), compare);
cout << "\n Sorted: ";
int size;
for (i = 0; i < nScores; i++)
cout << score[i] << ' ';
cout << endl;
int max = score[0];
int min = score[0];
for (i = 0; i < nScores; i++)
{
if (max < score[i]) max = score[i];
if (min > score[i]) min = score[i];
}
cout << " " << endl;
cout << "highest score: " << max << endl;
cout << "lowest score: " << min << endl;
cout << "average score: " << getAverage(score, nScores) << endl;
cout << "\n number of A scores: " << AScoreGreater(score, nScores);
cout << "\n number of B scores: " << BScoreGreater(score, nScores);
cout << "\n number of C scores: " << CScoreGreater(score, nScores);
cout << "\n number of passing scores: " << ABCScoreGreater(score, nScores);
cin >> size;
cin.ignore(1000, 10);
cin.get();
return 0;
}
```