Compare and contrast the different loops (for, while, do-while) we use in class.
Loops are very good for making games and other programs you need to run more than once. Lets start off with a for loop, a for loop is a loop where you know how many times you know its going to run. If you need it to run 5 times then you can use a for loop. Now a while loop can run infinite. If you need something that needs to run for a long amount of time, for example a game like pacman. It checks at the top of the code/ loop then it loops. A do-while is the same as a while loop but instead of checking to loop at the top it will check at the bottom of your code.
No comments:
Post a Comment