You're right, I didn't notice that.Originally Posted by Alexander the Pretty Good
At least my lazy brain got to think about some code again.![]()
You're right, I didn't notice that.Originally Posted by Alexander the Pretty Good
At least my lazy brain got to think about some code again.![]()
![]()
![]()
"Topic is tired and needs a nap." - Tosa Inu
It works now.![]()
I tried the code on one of the computers in university and it worked.
I wonder why it does not work on my computer?
So when are we moving on to conquest, boys?Originally Posted by The_Doctor
Don't spoil my fun, hey!
Nothing appears to be wrong with that code in your first post apart from the booleans need to be initialised.
“The majestic equality of the laws prohibits the rich and the poor alike from sleeping under bridges, begging in the streets and stealing bread.” - Anatole France
"The law is like a spider’s web. The small are caught, and the great tear it up.” - Anacharsis
There is. He wants loops, but his while loops don't do anything, because they end in a semicolon. His code IS, both syntactically, and semantically, correct, yes, but I very much doubt that was what he wanted (while loops that do nothing), at least from what he explained.Originally Posted by Manco Capac
Therapy helps, but screaming obscenities is cheaper.
I've just spotted that!Originally Posted by Blodrast
So without the semicolons and, if the booleans are initialised it should work? (bear in mind it has been a long time, and I am more C than C++ !) e.g.
???Code:#include <iostream.h> int main() { bool Easy=false; bool Medium=false; bool Hard=false; int Option=false; std::cout<< "Game intructions\n"; std::cout<< "Please select a difficulty level\n"; std::cout<< "1=Easy\n"; std::cout<< "2=Medium\n"; std::cout<< "3=Hard\n"; std::cout<< "4=Quit\n"; std::cin>> Option; if (Option == 1) { Easy = true; } if (Option == 2) { Medium = true; } if (Option == 3) { Hard = true; } if (Option == 4) { return 0; } while (Easy == true) { cout<< "Easy test works\n"; Easy = false; } while (Medium == true) { cout<< "Medium test works\n"; Medium = false; } while (Hard == true) { cout<< "Hard test works\n"; Hard = false; } return 0; }![]()
“The majestic equality of the laws prohibits the rich and the poor alike from sleeping under bridges, begging in the streets and stealing bread.” - Anatole France
"The law is like a spider’s web. The small are caught, and the great tear it up.” - Anacharsis
well, I'll be honest and I'll admit that I haven't actually tried the code - just looked at it.
But yeah, as far as I can tell, this should work just fine. Conceptually, it's correct, although it's always possible to miss a semicolon or some such.
Therapy helps, but screaming obscenities is cheaper.
Ok... I have had a second look...Originally Posted by Manco Capac
Manco Capac's code should work... if you initialise with a zero instead of false on the integer.
So, doc... you want to put a game in each of those loops?
Status Emeritus
![]()
LoL. I think you install his mini-game, and pick "Medium". No one ever picks medium. Then 'the plan' is revealed.Originally Posted by LeftEyeNine
![]()
Be well. Do good. Keep in touch.
Bookmarks