If statement running when conditions are not met.

Greetings,

I am currently messing about on the exercises in the articles section, and i am getting some strange results from the while (user == gullible) task.

I ran it through the debugger, and the int values were not met, but still the choice == 5 & count == 5 statements still printed. Could anyone shed some light on this?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>

int main()
{
	int choice = 0;
	int count = 0;

	std::cout << "Enter any integer, except 5! Don't you dare touch 5!" << std::endl;
	while (choice != 5 && count != 10)
	{
		count += 1;
		std::cin >> choice;
	}
	if (count == 10);
		std::cout << "Hey, you are more patient then me! Congrats!" << std::endl;
	if (choice == 5);
		std::cout << "Hey, you weren't suppose to enter 5!" << std::endl;


}


i am using Visual express 2010.

-Vladwow
closed account (z05DSL3A)
1
2
3
4
if (count == 10);
    std::cout << "Hey, you are more patient then me! Congrats!" << std::endl;
if (choice == 5);
    std::cout << "Hey, you weren't suppose to enter 5!" << std::endl;
<---should not have a ; here

<---or here
Well that bloody explains it, doesn't it.. So blind!
Topic archived. No new replies allowed.