My problem is I'm not sure how to get the program to identify each user input uniquely (in a loop). I suppose it would have been a lot easier if the users input, in this particular program,was fixed and not looped.
I have to get the average of the scores entered in each loop. As you will notice, a negative integer is used to exit the loop. The negative integer is not included in the loop counting or the average.
Code:
#include <stdio.h>
int main()
{
int user_input = 1;
int loop_count = -1;/*starts with -1 because the exit input (final input) is ignored*/
float user_input_average;
printf("The program calculates the average of scores you enter.\n");
printf("End with a negative integer.\n");
do
{
printf("Enter score (3-10):");
user_input++;
loop_count++;
scanf("%d", &user_input);
}
while(user_input > -1);
printf("You entered %d scores.\n", loop_count);
printf("Average score: %.2f\n", user_input_average);
return 0;
}