Answer:
#include <stdio.h>
int main()
{
int val, total = 0, count = 0;
float average = 0;
printf ("Enter in a list of numbers followed by the terminal value of -999\\");
scanf ("%d", &val);
while (val != -999){
if(val != -999){
total += val;
count++;
}
scanf("%d", &val);
}
average = (float)total / count;
printf ("For the list of %d numbers with a total of %d\\", count, total);
printf (" the average is: %15.5f\\", average);
return 0;
}
Step-by-step explanation:
Declare the total, count and average variables
In the while loop:
Add the entered number to the total and increment the count by 1 unless it is -999
Calculate average, divide total by count (Typecast the total as float to get decimal result)