Average Solution 2 (While Loop)

The advantage of this approach is that program only needs one prompt and one read operation.

#include <iostream>
using namespace std;

int main()
{
	int	score;
	int	count = 0;
	double	sum = 0;

	while (true)
	{
		cout << "Enter a score (-1 to end): ";
		cin >> score;

		if (score == -1)
			break;

		count++;
		sum += score;
	}

	cout << "The average is " << sum / count << endl;

	return 0;
}