If Statement Won't Show Up In Execution

Hi, guys!

My code's supposed to allow the user to enter six valid scores for a gymnast. However, if the score is below 0.0 or higher than 10.0, it's supposed to say 'That score is out of range!'.

However, when I execute the program, the if statement doesn't go into affect. Or, more specifically, it doesn't do it consistently. If I press continue in Visual Studio, sometimes the message shows up, but then it won't continue like it's supposed to.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 int main()
{
	double score;
	int current_size;
	double final_score;
	int counter = 1;

		cout << "Please enter your score for the gymnast: " << endl;
		
		for (counter = 1; counter <= 6; counter++)
		{
			cin >> score;

			if (score < 0.0 || score > 10.0)
				cout << "That score is out of range!" << endl;
		}

system("pause");
}
Because you can't exactly represent floating point numbers in binary.
https://isocpp.org/wiki/faq/newbie#floating-point-arith
Oh, it does allow me to enter six scores, but the if statement is still out of wack!
Thank you for the article! I'm going to give it a read! :)
Topic archived. No new replies allowed.