I am just trying to write a program where a user enters a grade and then when -1 is entered the program outputs the average grade and exits. The code I have written compiles and works, but it subtracts 1 from the average. Confused as to why this is happening:
//grades
#include <iostream.h>
int main()
{
int count = 0;
int total = 0;
int average;
int grades = 0;
while(grades != -1)
{
cout << "Please enter a grade(enter -1 to quit): \n";
cin >> grades;
total += grades;
count++;}
count--;
average = total / count;
cout << "Class average is: " << average << endl;
return 0;
}