Loops

Loops are how we as programmers do the same thing over and over. Instead of copying and pasting the same line(s) of code back-to-back, which can get clunky if done a few times and downright ugly if done more than once or twice, all modern programming languages contain some variations on the construction of a loop, which permits iteration and repetition. Loops allow us to do things like counting or even implement the fundamental basic flow of a game. Perhaps in Scratch, you used the Repeat __ Times block, or the FOREVER block. In C, we have three main types of loops: for, while, and do-while. Let’s dive in!