#include <stdio.h>
#include <stdlib.h>
int main()
{
int sum = 0;
int times = 0;
int number;
int average;
while ( number != 9999 ){
printf( " Type the number and i will make the average, 9999 to end:\n ");
scanf("%d", &number);
times = times + 1;
sum = number + sum;
}
average = (float)sum/times;
printf("The average is %f", average);
return 0;
}
When I run this program, average is returning -1 for any input. I would like to calculate the average of the sum of (n) numbers and if the user does not want to move on he uses Sentinel 9999 to exit the loop and end the program.