I try to solve the problem "While ( user == gullible )", from here http://www.cplusplus.com/forum/articles/12974/

and here is my solution,

 1234567891011121314151617181920212223242526 #include #include using namespace std; int main () { int answer; int question=0; cout << "Guess the number i am thinking about\n"; while (question<=10, question++) do { cout << "Insert the number other than " << question << ":"; cin >> answer; if (answer==5) cout << "You got me babe"; if (question==10) cout << "You are more patient than me, you win"; } return 0; }

but when i compile it, syntax error on return

i am sorry for this, i am only a noob :3
my question is, is there anything wrong with my solution?

Thanks :)
You're kind of combining a while loop with a do-while loop to make a while-do loop, which doesn't exist. Just remove "do" and it should work, or put the while part after the closing brace.
Umm, like this?

 12345678910111213141516171819202122232425 #include #include using namespace std; int main () { int answer; int question=0; cout << "Guess the number i am thinking about\n"; while (question<=10, question++) cout << "Insert the number other than " << question << ":"; cin >> answer; if (answer==5) cout << "You got me babe"; if (question==10) cout << "You are more patient than me, you win"; } return 0; }
You deleted the opening brace when you deleted the "do". Put that back and it should be fine. But why are you telling them to guess any number other than the number you're incrementing, rather than 5 every time? The question seems to be telling you to always tell them to not guess 5.
lol, hahahahahaha

anyway, problem solved, i made it like this

 12345678910111213141516171819202122232425262728 #include #include using namespace std; int main () { int answer; int question=0; cout << "Guess the number i am thinking about\n"; do { cout << "Insert the number other than " << question++ << ":"; cin >> answer; if (answer==5) cout << "You got me babe\n"; if (question==10) cout << "You are more patient than me, you win\n"; } while (question!=10, answer!=5); return 0; }

thanks everyone, i love you all :* THANKS !!! =)
Topic archived. No new replies allowed.