C++ Programming assignment program terminated with signal 6 : <p>This is the assignment: 
Write a program that outputs a histogram of student grades for an assignment. First, the program will input the number of grades and create a dynamic array to store the grades. Then, the program should input each student's grade as an integer and store the grade in the dynamic array.</p>

<p>The program should then scan through the array and compute the histogram. In computing the histogram, the minimum value of a grade is 0 but your program should determine the maximum value entered by the user. Use a dynamic array to store the histogram. Output the histogram to the console.</p>

<p>For example, if the input is:</p>

<p>Enter number of grades:
6
Enter grades (each on a new line):
20
30
4
20
30
30
Then the output histogram should be:</p>

<p>4 *
20 **
30 ***</p>

<p>My program works fine for me but when I submit it online it tells me "Program terminated with signal 6." Im not sure what this is and im not sure what in my program is causing it. Here is my code:</p>

<pre><code>#include&lt;iostream&gt;
#include&lt;iomanip&gt;

using namespace std;

int main()
{
    int numGrades;
    int i,j;
    int max = 0;
    int *list, *hist;

    cout &lt;&lt; "Enter number of grades:" &lt;&lt; endl;
    cin &gt;&gt; numGrades;
    list = new int[numGrades];
    cout &lt;&lt; "Enter grades (each on a new line):\n";

    for(i=0;i&lt;numGrades;i++)
    {
        cin &gt;&gt; *(list+i);
    }

    for(i=0;i&lt;numGrades;i++)
    {
        if(max&lt;*(list+i))
            max = *(list+i);
    }

    hist = new int[max];

    for(i=0;i&lt;=max;i++)
    {
        int no=0;
        for(int j=0;j&lt;numGrades;j++)
        {
            if(i==*(list+j))
                no++;
        }
        *(hist+i)=no;
    }

    cout &lt;&lt; "Histogram:" &lt;&lt; endl;
    for(i=0;i&lt;=max;i++)
    {
        if(*(hist+i)!=0)
        {
            cout &lt;&lt; right &lt;&lt; setw(3) &lt;&lt; i &lt;&lt; " ";
            for(j=0;j&lt;*(hist+i);j++)
                cout &lt;&lt; "*";
        }
        if(*(hist+i) != 0)
            cout &lt;&lt; endl;
    }

    delete []hist;
    delete []list;

    return 0;
}
</code></pre>

<p>Any help is appreciated, thank you.</p>
