title: Finding the average of an array using c
body: <p>I am new to coding in C and I am trying to get the average of the array but for some reason it is not calculating, it is giving me a result of 0.0. </p>
  
  <p>How can I fix this. Thanks</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  float grades_average(float grades[7]);
  int main() {
  
   float grades[7]={98.8, 97.9, 99.3, 99.8, 99.6, 99.4, 99.9};
   float average;
   average = grades_average(grades);
   printf("Average is: %.2f",average);
  
  
   return 1;
  }
  float grades_average(float grades[7]){
   int i;
   float sum = 0;
   float average = 0.0;
   /* calculate the sum of grades using for loop*/
      for(i = 0; i &lt;= 7; i++){
         sum = sum + grades[7];
      }
   average = sum/7;
  
   return average;
  }
  </code></pre>
  
  <p>The output is: </p>
  
  <pre><code>Average is: 0.00
  </code></pre>