1. Counting loops

I'm busy with a code (in the learning phases) and everything is working just fine, but I wanted to know how you can print the number of times a program had to loop (loop_count).

The program:

The point of the program is that the user will be prompted to enter a score(s). The program will stop prompting for the score or end the loop when the user enters a negative integer.

Once the loop has ended, the number of scores will be counted and printed in the following text.

Lets say the user entered 8 > 7 > 5 > -4 // the negative is ignore and not added to the
//total scores counted.
You entered 3 scores.

Example:
Code:
```#include <stdio.h>

int main()
{
int user_input = 1;
int loop_count;

printf("The program calculates the average of scores you enter.\n");
printf("End with a negative integer.\n"); //note that the loop ends when the user
//enters a negative integer
do
{
printf("Enter score (3-10):");
user_input++;
scanf("%d", &user_input);
}
while(user_input > -1);

loop_count = ??? ; //I'm not sure how to construct this. The loop_count should not
//include the negative integer, used to exit the loop

printf("You entered %d scores.\n", loop_count);

return 0;
}```
The final product should look like this:

Code:
```The program calculates the average of scores you enter.
End with a negative integer.
Enter score (3-10):5
Enter score (3-10):8
Enter score (3-10):8
Enter score (3-10):6
Enter score (3-10):5
Enter score (3-10):7
Enter score (3-10):5
Enter score (3-10):-1
You entered 7 scores.```

2. Add a variable inside the loop previously initialized to 0 and increment it each time loop gets executed.

3. I have my "blind to what is in front of my face" moments too, so here's a clue that will hopefully ring those bells:

It is extremely similar to the number of the times the loop iterates:
Code:
```int loop_count = 0;
do
{
printf("Enter score (3-10):");
user_input++;
loop_count++;  // this happened once each time
scanf("%d", &user_input);
}
while(user_input > -1);```

4. Code:
```int times = 0;

do
{
printf("Enter score (3-10):");
user_input++;
scanf("%d", &user_input);
times++;
}
...```

5. brilliant!! I had tried loop_count++ before and it gave me a ridiculous (large) number and I now realize (thanks to you two), I had forgotten to declare: int loop_count = 0;

Thank you all!

The final code checks correct and looks like this:

Code:
```#include <stdio.h>

int main()
{
int user_input = 1, loop_count = 0;
float loop_count_average; //still working on this

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);

loop_count = loop_count--;//filters the negative integer

printf("You entered %d scores.\n", loop_count);
printf("Average score: %.2f\n");//still working on this

return 0;
}```
Just out of curiosity, what does the void in int main(void) mean?