Could somebody please help me with this program. This is my first time working with an EOF loop. This program simply adds up all the input numbers. My task is to have the last wanted input terminated by an EOF. However, when I run my program, my loop is infinite. Can someone please help me? I would really appreciate it.
/* A program to compute the sum of numbers given on the input */
#include <stdio.h>
int main()
{
/* declarations */
float x;
float y;
float sum;
float number;
/* Initialize the sum */
/* Get the first input */
printf("Enter the first input (EOF to end): \n");
number = scanf("%f", &x);
/* While there is more input */
while (number != EOF)
{
/* Accumulate the sum */
sum = x + sum;
/* Get the next input */
printf("Enter the next input (EOF to end): \n");
number = scanf("%f", &x);
}
/* Print the results */
printf("sum = %f\n", sum);
}