Then it asks the user whether it wants to skip 5 or not, if they say YES I want it to go 1 2 3 4 6 7 8 -- >
So I said something like:
1 2 3 4 5
int number
char yesorno
if ( yesorno == 'Y' && yesorno=='y' && number=5 )
continue;
is that how it's suppose to be used? I just want it to skip one loop and go to the next number. But it freezes up the program after the user enters Y ( for yes).
First create your variable's.
char yesorno;<--- notice semicolon
int NumberToCountTo;<--- used this long name for readability
Then you could prompt for user input
cout << "Do you want to skip number 5?";
cin >> yesorno;
Then create your loop.
for(int LoopIterator = 0;LoopIterator <= NumberToCountTo;LoopIterator++)
{
while (LoopIterator !== 5)
{
cout << "LoopIterator\n";<--- Use this if you want the number's on new line each.
cout << "LoopIterator" << " ";<--- Or this if all on same line with space's.
}
}
That should work, I didn't test it but it should. Post back and let me know if it worked, or if you got any question's.
yesorno can not be 'Y' and 'y' at the same time. I suppose you either mean "if ( yesorno != 'Y' && ...)" or you mean "if ( yesorno == 'Y' || yesorno == 'y' ...)"
Ciao, Imi.
PS: What bolo809 said is still true. "number=5" is also most probably not what you want too. number=5 sets number to 5 and does no checking.