Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 22 Online
OpenStudy (anonymous):

In problems set 1, question 3, the solution has a while loop where the condition is simply "True". How does that loop ever end?

OpenStudy (bibby):

you'd have to post the full code. as far as I can tell ``` while(true){ //do stuff break; //necessary to break an otherwise infinite loop } ```

OpenStudy (rsmith6559):

In that type of setup, the while loop won't ever end. Usually something in the code block will break out of the loop, ending it. Don't think it's a silly idiom. It's very useful for waiting for connections in server sockets or waiting for events in GUIs ( Graphical User Interface ).

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!