title: My simple for loop just doesn't work and I don't know why
body: <p>I'm trying to make a something which would just take a user generated input, place it into a matrix and just calculate the average across the rows.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  
  int main(void) {
      int grades[5][5];
      float average;
      int i, j; 
      int n, m; // number of columns and rows
      printf("Enter the number of Rows then the number of Columns: ");
      scanf("%d %d", &amp;n, &amp;m);
  
      for(i = 0; i&lt;=n; i++){
          for(j = 0; j&lt;=m; j++){
              printf("Input the number for place %d %d -&gt; ", &amp;i, &amp;j);
              scanf("%d", grades[i][j]);
          }
      }
      // the problem is that i keep getting wild input numbers... 
      // instead of i and j going 0 0, 0 1, 0 2... 1 0, 1 1, 1 2... 
      // it goes to like 2293320 2293316 and then does not move. 
      // (the huge numbers are the first and only outputs i get from the input numbers message)
  
  
      //this should be working
      for (i = 0; i &lt;= n; i++) {
          average = 0;
          for (j = 0; j &lt;= m; j++) {
              average = average + grades[i][j];
          }
          average = average/5;
  
          printf("The average marks obtained in subject %d is: %.2f\n", i, average);
      }
  
  
      return 0;
  }
  </code></pre>
  
  <p>Thank you for your help. :D</p>