title: program.exe has stopped working after running it
body: <p>I don't know what problems I got. I build with no errors and everything is okay. Honestly, I got this program. However, my professor does't allow global variables. So, I put my variables into main function and other void functions. However, when I run it, it say " program.exe has stopped working". I don't know how to fix it. I may use pointer somewhere wrong or maybe I calculated the standard deviation wrong. I don't know.  Any help will be appreciate. Thank you very much !!! 
  Here is my inputFile "scores.txt" : </p>
  
  <p>46</p>
  
  <p>85 100 90 85 97 92 72 88 79 86 97 89 67 96 84 96 93 77 56 77 85 100 84
  92 88 67 97 86 95 94 73 68 76 80 99 78 87 96 85 64 93 81 92 93 74 65</p>
  
  <p>Here is my code: </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;cmath&gt;
  
  using namespace std;
  
  const int SIZE =46; // This is the maximum student's scores
  
  
  // Here is my function prototyoe
  void readScores   ( int array[], int *pLast);
  void insertionSort( int *ptr, int SIZE);
  void displayArray ( int array[], int *pLast);
  double calAverage ( int array[], int *pLast);
  int *calLowest    ( int array[], int *pLast);
  int *calHighest   ( int array[], int *pLast);
  double calStandDevi (int array[], int *pLast);
  void printResult   ( int array[], int *pLast);
  
  int main()
  {
      int num_scores;
      int array[SIZE];
      int *ptr = array;      // Here is my pointer that point to the array
      int *pLast = array + SIZE-1;    // Here is my last pointer.
  
      // I need to initialize the average, lowest, highest scores and stand deviation so that I can call my function.
      double avg, stand_deviation;
      int *get_lowest, *get_highest;
  
      // to open, work and save my file. I need to initialize this.
      ifstream inputFile;
      ofstream outputFile;
  
      cout &lt;&lt; "Welcome to my third program!!!" &lt;&lt; endl;
      cout &lt;&lt; endl;
  
      // Here is my eight function call.
      readScores( array, pLast);
      insertionSort(&amp;array[0],SIZE);
      displayArray(array,pLast);
      avg = calAverage(array,pLast);
      get_lowest = calLowest(array,pLast);
      get_highest = calHighest(array,pLast);
      stand_deviation = calStandDevi(array,pLast);
      printResult( array, pLast);
  
      //cout &lt;&lt; num_scores &lt;&lt; endl; // just the test if I read the correct scores from the inputfile
  
  
      return 0;
  }
  // Here is my first function definition which is read scores from the input file.
  void readScores ( int array[], int *pLast )
  {
      int num_scores;
      ifstream inputFile;
      inputFile.open("scores.txt");   // I open the file.
      inputFile &gt;&gt; num_scores;        // I read the file.
      for ( int *ptr = array; ptr &lt;= pLast; ptr++)
          {
              inputFile &gt;&gt; *ptr;
          }
          inputFile.close();  // I close the file.
  
  }
  // Here is my second function definition to sort the array in ascending order using Insertion Sort.
  void insertionSort(int *ptr, int SIZE)
  {
     for (int curr =1; curr &lt; SIZE; curr++)
         {
             int hold = *(ptr+curr);
             int back = *(ptr-1+curr);
               while( hold &lt; *(ptr-1+curr) &amp;&amp; (curr &gt; 0))
                  {
                      *(ptr+curr)= *(ptr-1+curr);
                      curr--;
                  }
              *(ptr+curr) = hold;
         }
  }
  // Here is my third function definition which  sorted array 10 numbers per line.
  void displayArray ( int array[], int *pLast)
  {
      int count =0;
  
      for (int *ptr = array; ptr &lt;= pLast; ptr++)
      {
          count++;
          cout &lt;&lt; *ptr &lt;&lt; " ";
          if ( count % 10 == 0)
          {
          cout &lt;&lt; endl;
          }
      }
      cout &lt;&lt; endl;
  }
  // Here is my fourth function definition which calculate the average.
  double calAverage( int array[], int *pLast)
  {
      double sum1 =0;
      double avg;
      for ( int *ptr = array; ptr &lt;= pLast; ptr++)
         {
          sum1 += *ptr;
          avg = sum1/SIZE;
         }
         return avg;
  }
  // Here is my fifth function definition which calculate the lowest score.
  int *calLowest ( int array[], int *pLast)
  {
      int *get_lowest = array;
      for ( int *ptr = array; ptr &lt;= pLast; ptr++)
      {
          if(*get_lowest &gt; *ptr)
              get_lowest = ptr;
      }
      return get_lowest;
  }
  // Here is my sixth function definition which calculate the highest score.
  int *calHighest ( int array[], int *pLast)
  {
      int *get_highest = array;
      for ( int *ptr = array; ptr &lt;= pLast; ptr++)
          {
              if ( *get_highest &lt; *ptr)
                    get_highest=ptr;
          }
      return get_highest;
  }
  // Here is my seventh definition which calculate the stand deviation
  double calStandDevi (int array[], int *pLast)
  {
      double sum2=0;
      double avg;
      double sum_deviation=0.0;
      double stand_deviation = 0.0;
      for ( int *ptr = array; ptr &lt;= pLast; ptr++)
          {
              sum2 += *ptr;
              avg = sum2/SIZE;
              sum_deviation += pow((*ptr-avg), 2.0);
              stand_deviation = sqrt(sum_deviation/SIZE-1);
          }
      return stand_deviation;
  }
  // Here is my last function definition which print the result.
  void printResult ( int array[], int *pLast)
  {
      double avg, stand_deviation;
      int *get_lowest, *get_highest;
  
      cout &lt;&lt; "The average score is " &lt;&lt; avg &lt;&lt; endl;
      cout &lt;&lt; "The lowest score is " &lt;&lt; *get_lowest &lt;&lt; endl;
      cout &lt;&lt; "The highest score is " &lt;&lt; *get_highest &lt;&lt; endl;
      cout &lt;&lt; "The standard deviation is " &lt;&lt; stand_deviation &lt;&lt; endl;
      cout &lt;&lt; endl;
      cout &lt;&lt; "Have a great day!!!" &lt;&lt; endl;
  }
  </code></pre>