I am trying to make a program that calculates the average score of class and counting the number of A, B, C, D students. Now I am trying another idea: If the test scores are randomly given to students(between 60 to 100), how can I input those random scores into an array? Mine requires users to input all scores one by one. I would like to know how to fill in the array automatically. 

```
#include <iostream>
#include <cstdlib>
using namespace std;

double Average(double *scores, int N)
{
    int i;
    double total = 0;
    for(i = 0; i < N; i++)
    {
        total = total+scores[i];
    }
    return total / N;
}

int Agrade(double *scores, int N)
{
    int i;
    int count = 0;
    for(i = 0; i < N; i++)
    {
        if(scores[i] >= 90 && scores[i] <= 100) count++;
    }
    return count;
}

int Bgrade(double *scores, int N)
{
    int i;
    int count = 0;
    for(i=0; i < N; i++)
    {
        if(scores[i] >=80 && scores[i] < 90) count ++;
    }
    return count;
}

int Cgrade(double *scores, int N)
{
    int i;
    int count = 0;
    for(i=0; i < N; i++)
    {
        if(scores[i] >=70 && scores[i] < 80) count ++;
    }
    return count;
}

int Dgrade(double *scores, int N)
{
    int i;
    int count = 0;
    for(i=0; i < N; i++)
    {
        if(scores[i] >=60 && scores[i] < 70) count ++;
    }
    return count;
}
int Fgrade(double *scores, int N)
{
    int i;
    int count = 0;
    for(i=0; i < N; i++)
    {
        if(scores[i] < 60) count ++;
    }
    return count;
}

int main(){
int i;
int N;
double *scores; 

std::cout<<"How many test scores? "<<endl;
cin>>N;
    if(N<1){
    std::cout<<"Invalid input. try again"<<endl;
    }
    else if(N>25)
    {
    std::cout<<"1-25 only."<<endl;    
    }
    else if(N>0 && N<25){
    std::cout<<"Total number of test is: "<< N << endl;      
    }

    scores = new double[N];

    for(i = 0; i < N; i++)
    {
        cout << "Randomly generating score of students" << i + 1 << ": "; 
        cout << (rand() % 40 + 60) << endl; //Trying to give random scores between 60-100
        if(!(cin >> scores[i]) || scores[i] < 0 || scores[i] > 100)
        {
            if(!cin)
            {
                cin.clear();
                cin.ignore(1000, '\n');
            }
            cout << "Score must be between 0 to 100.\n\n"; i--; continue;
        }
    }

    double averagescore = Average(scores, N);
    int scoreAcount = Agrade(scores, N);
    int scoreBcount = Bgrade(scores, N);
    int scoreCcount = Cgrade(scores, N);
    int scoreDcount = Dgrade(scores, N);
    int scoreFcount = Fgrade(scores, N);
    cout << "The average test score : " << averagescore << endl;
    cout << "The number of A grades : " << scoreAcount << endl;
    cout << "The number of B grades : " << scoreBcount << endl;
    cout << "The number of C grades : " << scoreCcount << endl; 
    cout << "The number of D grades : " << scoreDcount << endl;
    cout << "The number of F grades : " << scoreFcount <<endl;
    cout << endl;

return 0;
} 

```

Can I just modify this part to make it work? 

```
for(i = 0; i < N; i++)
        {
            cout << "Randomly generating score of students" << i + 1 << ": "; 
            cout << (rand() % 40 + 60) << endl; //Trying to give random scores between 60-100
            if(!(cin >> scores[i]) || scores[i] < 0 || scores[i] > 100)
            {
                if(!cin)
                {
                    cin.clear();
                    cin.ignore(1000, '\n');
                }
                cout << "Score must be between 0 to 100.\n\n"; i--; continue;
            }
        }

```

or do I need to modify all functions?