title: Read numbers from file and calculate sum and average
body: <p>I need to write a program to read numbers from a file and calculate the averages.Read the first number. It's the group size. Read subsequent numbers for the group size. Add them and calculate the average. This is what I got so far:</p>
  
  <pre><code>int main()
  {
      int num1, num2, num3, num4, sum, gsize;
      FILE *inFile;
      char fname[30];
  
      printf("Enter a file name: ");
      gets(fname);
  
      inFile = fopen(fname, "r");
      if (inFile == NULL)
      {
          printf("\nFailed to open file.\n");
          exit(1);
      }
  
  
      while (fscanf(inFile, "%d %d %d %d %d %d",&amp;gsize, &amp;num1, &amp;num2, &amp;num3, &amp;num4) != EOF)
      {
          printf("Group Size = %d\n num1 = %-12d num2 = %-18d num3 = %-24d num4 = %-30d %d\n", gsize, num1, num2, num3, num4, sum);
  
  
      }
      fclose(inFile);
  
  }
  </code></pre>
  
  <p>Please, help me to figure out how to count and print it so I get this output:</p>
  
  <pre><code>Enter an input file name: numbers.dat
  Group Size = 2
  i = 1 number = 1 Sum = 1
  i = 2 number = 2 Sum = 3
  Average = 1.50
  
  Group Size = 3
  i = 1 number = 1 Sum = 1
  i = 2 number = 2 Sum = 3
  i = 3 number = 3 Sum = 6
  Average = 2.00
  
  Group Size = 4
  i = 1 number = 1 Sum = 1
  i = 2 number = 2 Sum = 3
  i = 3 number = 3 Sum = 6
  i = 4 number = 4 Sum = 10
  Average = 2.50
  </code></pre>
  
  <p>This is my input:</p>
  
  <pre><code>2 1 2
  3 1 2 3
  4 1 2 3 4
  </code></pre>