title: C Programming (GPA Calculator)
body: <p>Very stuck on this problem.  I FINALLY got the average to come out, but it gives it as negative 32 million or something.  Here is my code:</p>
  
  <pre><code> #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  
  int main()
  {
  
  float fArray[30];
  int choice = 0;
  int x = 0;
  float total = 0;
  float avg = 0;
  
  printf("1. Calculate GPA Average");
  printf("\n2. Enter GPA");
  printf("\n3. Quit");
  printf("\n\nEnter your choice (1-3):  ");
  scanf("%d", &amp;choice);
  
  if(choice == 2)
  {
      printf("\n\nEnter GPA:  ");
      scanf("%.2f\n\n", &amp;fArray[x]);
      total = total + fArray[x];
  }
  else if(choice == 3)
  {
      return 0;
  }
  else if(choice == 1)
  {
  printf("The average is:  %f", total / x);
  }
  
  for(x = 1; x &lt; 30; x++)
  {
      fflush(stdin);
      int temp = 0;
      printf("1. Calculate GPA Average");
      printf("\n2. Enter GPA");
      printf("\n3. Quit");
      printf("\n\nEnter your choice (1-3):  ");
      scanf("%d", &amp;temp);
  
      if(temp == 2)
      {
          printf("\n\nEnter GPA:  ");
          scanf("%.2f\n\n", &amp;fArray[x]);
      }
      else if(temp == 3)
      {
          break;
      }
      else if(temp == 1)
      {
  printf("The average is:  %f", total / x);
      }
  } 
  
  system("pause");
  }
  </code></pre>