I'm going through and doing the beginner exercises(http://www.cplusplus.com/forum/articles/12974/) to review some of the earlier stuff I learned in my first C++ class I took two semester ago and I'm having an issue with the While( user == gullible ) program.
#include <iostream>
usingnamespace std;
int main() {
int count = 0, number;
cout << "Put in any number other than five. " << endl;
cin >> number;
while (number != 5) {
cout << "Put in any number other than five." << endl;
cin >> number;
count++;
if (count == 10) {
cout << "Wow, you're more patient then I am, you win." << endl;
break;
}
elseif (number == 5) {
cout << "Hey! You weren't supposed to enter 5!" << endl;
}
}
system("pause");
return 0;
}
My issue is that after I enter 5, it doesn't print out "Hey! You weren't supposed to enter 5!". Why is that? Is there a better way that I can do this? I also have one more question about cin.get() use over system("pause"). I know system("pause") is tied to the Windows OS(at least from what I've read), but when I use cin.get(), it doesn't pause the CMD window. How can I make it pause the CMD window so I don't have to use system("pause") anymore?