title: What code I must input to display the ranks, student numbers and their average using array?
body: <p>I want to show the ranks, student numbers and average but idk how. Here's my code:</p>
  <pre><code>/* CODES */
  #include&lt;iostream&gt;
  using namespace std;
  
  int main() {
      int grades[100];
      float sum, ave, add, score1, score2, score3, score4;
      
      cout &lt;&lt; &quot;How many students do you want to input? &quot;;
      cin &gt;&gt; grades[100];
          
      for (int i=0; i&lt;grades[100]; i++){
          cout &lt;&lt; &quot;\nInput Average Grade of Student #&quot; &lt;&lt; i+1 &lt;&lt; endl;
  
          for (int j=0; j&lt;1; j++){
          cout &lt;&lt; &quot;First Grading Period: &quot;;
          cin &gt;&gt; score1;
          
          for (int attempt1=0; attempt1&gt;=0; attempt1++){
              if (score1 &lt; 65 || score1 &gt; 100){
                 cout &lt;&lt; &quot;INVALID INPUT. Input again: &quot;;
                 cin &gt;&gt; score1;
              }
              else{
                  break;
              }
          }
      }
  
          for (int j=0; j&lt;1; j++){
          cout &lt;&lt; &quot;Second Grading Period: &quot;;
          cin &gt;&gt; score2;
          
          for (int attempt2=0; attempt2&gt;=0; attempt2++){
                  if (score2 &lt; 65 || score2 &gt; 100){
                  cout &lt;&lt; &quot;INVALID INPUT. Input again: &quot;;
                  cin &gt;&gt; score2;
                  }
                  else{
                  break;
                  }
              }
          }
  
          for (int j=0; j&lt;1; j++){
          cout &lt;&lt; &quot;Third Grading Period: &quot;;
          cin &gt;&gt; score3;
  
          for (int attempt3=0; attempt3&gt;=0; attempt3++){
          if (score3 &lt; 65 || score3 &gt; 100){
                  cout &lt;&lt; &quot;INVALID INPUT. Input again: &quot;;
                  cin &gt;&gt; score3;
                  }
                  else{
                  break;
                  }
              }
          }
  
          for (int j=0; j&lt;1; j++){
          cout &lt;&lt; &quot;Fourth Grading Period: &quot;;
          cin &gt;&gt; score4;
  
          for (int attempt4=0; attempt4&gt;=0; attempt4++){
          if (score4 &lt; 65 || score4 &gt; 100){
                  cout &lt;&lt; &quot;INVALID INPUT. Input again: &quot;;
                  cin &gt;&gt; score4;
                  }
                  else{
                  break;
                  }
              }
          }
          
      
          sum = score1+score2+score3+score4;
          ave = sum/4;
             
          cout &lt;&lt; &quot;=============================&quot; &lt;&lt; endl;
          cout &lt;&lt; &quot;Average of Student #&quot; &lt;&lt; i+1 &lt;&lt; &quot;: &quot; &lt;&lt; ave &lt;&lt; endl;  
      }
      
      
      
      return 0;
  }
  </code></pre>
  <p>The output of the code above, it shows the grades and average of every students that I inputted:</p>
  <pre><code>How many students do you want to input? 3
  
  Input Average Grade of Student #1
  First Grading Period: 85
  Second Grading Period: 85
  Third Grading Period: 85
  Fourth Grading Period: 85
  =============================
  Average of Student #1: 85
  
  Input Average Grade of Student #2
  First Grading Period: 100
  Second Grading Period: 100
  Third Grading Period: 100
  Fourth Grading Period: 100
  =============================
  Average of Student #2: 100
  
  Input Average Grade of Student #3
  First Grading Period: 90
  Second Grading Period: 90
  Third Grading Period: 90
  Fourth Grading Period: 90
  =============================
  Average of Student #3: 90
  </code></pre>
  <p>Now the problem is how I will display the ranks, student numbers and average. This is the sample output for the ranks, student numbers, and average that I want to display:</p>
  <pre><code>RANKS STUDENT NO. AVERAGE
  1     2           100
  2     3           90
  3     1           85
  </code></pre>