What is a while loop? Explain how to set up while loops. What lines of code do you need to ensure that a while loop works correctly? What mistakes have you encountered so far when you write while loops?
A while loops lets you repeat a set of commands over and over until the user inputs a key to exit.
while (input != 'q'){
}
you will need to make sure what you want is in the while loop, a mistake I've made a couple times. Also the 'q' that is represented above, I made it a command in a game that I created but when I pressed q it close me out instead of doing the function that coded it to do. you can also make the 'q' into a number or a string. all you need to do is change the variable to the correct variable that matches the input statement.
No comments:
Post a Comment