title: Calculating the mean of part of an array
body: <p>I am trying to calculate the mean of high and low temperatures entered by a user and the number of days that can be included are between 1 and 4 however, I'm having difficulty understanding how to go about this. The code I wrote yields a completely irrelevant number. Here's my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main (void)
  {
      int i;
      int limit;
      int day[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
      int high[10],low[10];
  
      printf("---===IPC Temperature Analyzer V2.0===---\n");
  
      printf("Please enter the number of days between 3 and 10, inclusive: ");
      scanf("%d", &amp;limit);
      while (limit &lt;= 2 || limit &gt;= 11) {
          printf("Invalid entry, please enter a number between 3 and 10,   inclusive: ");
          scanf("%d", &amp;limit);
      }
  
      for(i = 0;i &lt; limit; i++) {
          printf("Day %d - High: ", day[i]);
          scanf("%d", &amp;high[i]);
          printf("Day %d - Low: ", day[i]);
          scanf("%d", &amp;low[i]);
      }
  
      printf("\nDay Hi Low\n");
      for (i = 0; i &lt; limit; i++) {
          printf("%d   %d    %d\n", day[i], high[i], low[i]);
      }
  
      int max = 0;
      int min = 0;
  
      for (i = 0; i &lt; limit; i++) {
          if (high[max] &lt; high[i])
              max = i;
          if (low[min] &lt; low[i])
              min = i;
      }
  
      printf("\nHighest temperature was: %d on day %d", high[max], day[max]);
      printf("\nLowest temperature was: %d on day %d ", low[min], day[min]);
  
      int n;
      int avg = high[i] + low[i]/i;
  
      printf("\nEnter a number between 1 and 4 to see the average temperature for the entered number of days, enter a negative number to exit\n");
      scanf("%d", &amp;n);
  
      while (n &gt; 4) {
          printf("Invalid entry, please enter a number between 1 and 4, inclusive: ");
          scanf("%d", &amp;n);
      }
  
      while (n &lt; 0) {
          printf("Goodbye!\n");
          exit(0);
      }
  
      for (i = 0; i &lt; n; i++) {
          printf ("The average temperature up to day %d is: %d", day[i], avg);
      }
      return 0;
  }
  </code></pre>