the program gives me an infinite loop

```
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
void loadScores( int [], int & );
double average( int [], int );
double deviation(int [], double, int );
void frequency( int [], int[], int, double, double);
void sortScores(int [], int );
void displayArray( int [], double [], int, int [], double, double );
void comp( double [], double, double );
int main ()
{
int x[100];
double compe[4];
double sum = 0;
int amount = 0;
int Gfrequency[] = {0, 0, 0, 0, 0};
double averageG;
double total;
double std;
loadScores( x, amount );
averageG = average( x, amount );
std = deviation(x, averageG, amount );
sortScores(x, amount );
comp(compe, averageG, std);
displayArray(x, compe, amount, Gfrequency, averageG, std );
return 0;
}
void displayArray( int x[], double compe[], int size , int Gfrequency[], double average, double std)
{
int i = 0;
int j = 0;
cout<<"Grade Distribution"<<endl;
cout<<"=================="<<endl;
cout<<"A: " <<endl;
while( x[i] >= compe[j] )
{
cout<< x[i] << " ";
i++;
Gfrequency[j]++;
}
j++;
cout<< "B: " <<endl;
while( x[i] >= compe[j] )
{
cout<< x[i] << " ";
i++;
Gfrequency[j]++;
}
j++;
cout<< "C: " <<endl;
while(x[i] >= compe[j] )
{
cout<< x[i] << " ";
Gfrequency[j]++;
}
j++;
cout<< "D: " <<endl;
while ( x[i] >= compe[j] )
{
cout<< x[i] << " ";
i++;
Gfrequency[j]++;
}
j++;
cout<< "F: " <<endl;
while (i < size)
{
cout<< x[i] << " ";
i++;
Gfrequency[j]++;
}
cout<< "==================" <<endl;
cout<< "Grade Frequency" <<endl;
cout<< "===============" <<endl;
cout<< "A: "<< Gfrequency[0] <<endl;
cout<< "B: "<< Gfrequency[1] <<endl;
cout<< "C: "<< Gfrequency[2] <<endl;
cout<< "D: "<< Gfrequency[3] <<endl;
cout<< "F: "<< Gfrequency[4] <<endl;
cout<< "===============" <<endl;
cout<< "n = " << size <<endl;
cout<< "Class Average: " <<average<<endl;
cout<< "Class STD: " << std <<endl;
}
void loadScores( int x[], int &size )
{
size = 0;
while(!cin.eof())
{
cin>> x[size];
size++;
}
}
void sortScores( int x[], int size )
{
for( int i = 0; i < size - 1; i++ )
{
for ( int j = 0; j < size - 1; j++ )
{
int temp;
if ( x[j] < x[j + 1] )
{
temp = x[j];
x[j] = x[j + 1];
x[j + 1] = temp;
}
}
}
}
double average( int x[], int size)
{
double sum = 0;
double avg;
for ( int i = 0; i < size; i++ )
{
sum += x[i];
}
avg = sum / size;
return avg;
}
double deviation( int x[], double average, int n )
{
double total = 0;
double std;
for (int i = 0; i < n; i++ )
{
total += (x[i] - average)*(x[i] - average);
}
total /= n;
return sqrt(total);
}
void comp( double compe[], double average, double std)
{
compe[0] = average + 2 * std;
compe[1] = average + std;
compe[2] = average - std;
compe[3] = average - 2 * std;
}
```