C programming "while" loop help?

I am trying to write a C program to take numbers from an input file (input.dat), calculate the sum and average of the numbers for each row, and display them in a form of table and in an output file (result.out).