title: Segmentation fault when trying to get lowest number from user inputted array
body: <p>I'm making a program that calculates the average of user inputted tests, after the user has inputted the number of tests, the user then has to input every grade for the number of tests inputted, after that the program will then read into the array of grades inputted then get the lowest grade, after that the program will calculate the average, then output that, then output the lowest grade, then call function "letter();" to get the letter grade based on the value on the average. but when it goes into getting the lowest number from the array it gives me a segmentation fault that I can't fix</p>
  
  <p>I have tried to redo that part of the code to no avail</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  void letter();
  
  int average;
  
  int main()
  {
      int a[100], i, sum = 0, num, lowest, test;
  
      printf("Enter the numbers of tests: ");
      scanf("%d", &amp;test);
  
      while (test &gt; 100 || test &lt;= 0)
      {
          printf("Error! The number of tests should be in range of (1 to 100).\n");
          printf("Enter the number again: ");
          scanf("%d", &amp;test);
      }
  
      for(i = 0; i &lt; test; ++i)
      {
          printf("%d. Enter grade for this test: ", i+1);
          scanf("%d", &amp;a[i]);
          sum += a[i];
      }
  
      lowest = a[0];
  
      for (i = 0; i &lt; num; i++)
      {
          if (a[i] &lt; lowest)
          {
              lowest = a[i];
          }
      }
  
      average = sum / test;
      printf("Average = %d", average);
  
     return (0);
  }
  
  void letter()
  {
      if (average == 0 || average &lt;= 60)
      {
          printf("Your average is a F. \n");
      }
  
      else if (average &lt;= 70 || average &gt;= 61)
      {
          printf("Your average is a D. \n");
      }
  
      else if (average &lt;= 80 || average &gt;= 71)
      {
          printf("Your average is a C. \n");
      }
  
      else if (average &lt;= 90 || average &gt;= 81)
      {
          printf("Your average is a B. \n");
      }
  
      else if (average &lt;= 100 || average &gt;= 91)
      {
          printf("Your average is a A. \n");
      }
  }
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>I added</p>
  
  <pre><code>printf("Your average is: %d \n", average);
  
  printf("The lowest grade is: %d \n", lowest);
  
  letter();
  </code></pre>
  
  <p>after </p>
  
  <pre><code>average = sum / test;
  </code></pre>
  
  <p>and changed the letter function to this but doesnt give me correct letter grade with average</p>
  
  <pre><code>void letter()
  {
      if (average &gt;= 0 || average &lt;= 59)
      {
          printf("Your average is a F. \n");
      }
  
      else if (average &gt;= 60 || average &lt;= 69)
      {
          printf("Your average is a D. \n");
      }
  
      else if (average &gt;= 70 || average &lt;= 79)
      {
          printf("Your average is a C. \n");
      }
  
      else if (average &gt;= 80 || average &lt;= 89)
      {
          printf("Your average is a B. \n");
      }
  
      else if (average &gt;= 90 || average &lt;= 99)
      {
          printf("Your average is a A. \n");
      }
  }
  </code></pre>
  
  <p><strong>EDIT #2</strong>
  Changed letter function to this, now it works, thanks everyone for you help and taking your time to help me out.</p>
  
  <pre><code>void letter()
  {
      if (average == 0 &amp;&amp; average &lt;= 60)
      {
          printf("Your average is a F. \n");
      }
  
      else if (average &lt;= 70 &amp;&amp; average &gt;= 61)
      {
          printf("Your average is a D. \n");
      }
  
      else if (average &lt;= 80 &amp;&amp; average &gt;= 71)
      {
          printf("Your average is a C. \n");
      }
  
      else if (average &lt;= 90 &amp;&amp; average &gt;= 81)
      {
          printf("Your average is a B. \n");
      }
  
      else if (average &lt;= 100 &amp;&amp; average &gt;= 91)
      {
          printf("Your average is a A. \n");
      }
  }
  </code></pre>