Okay, basically, i need to find the average grade in student's group, without knowing their exact number.

The following code given below:

```
#include <stdio.h>

int main (void)
{
    unsigned int counter;
    int grade;
    int total;

    float average;

    total = 0;
    counter = 0;

    printf( "%s", "Enter grade, -1 to end: " );
    scanf( "%d", &grade);

    while (grade != -1)
    {
        total = total + grade;
        counter = counter + 1;

        printf( "%s", "Enter grade, -1 to end: " );
        scanf( "%d", &grade );
    }

    if ( counter != 0 )
    {
        average = (float) total / counter;

        printf( "Class average is %.2f\n", average);
    }

    else
    {
        puts( "No grades were entered" );
    }

    return 0;
}

```

Basically, this one should give me the class average of any number of entered grades. But whenever i enter random number of grades and then print "-1" to stop the cycle, it prints the message "Class average is 0". No matter how many figures you've entered. The only condition that works properly is when you don't print any grades and print "-1" at once, then "No grades were entered" works here. 

Help me please, with that. Because it is either blind me or some serious mistake i can't see. Third variant includes mistake in the book.

Looking forward to your help!