14. How Can I Do the Same Stuff Over and Over?
With while and do-while Loops
Now that you’ve learned the operators, you’re ready to play “loop-the-loop” with your programs. A loop is simply a section of code that repeats a few times. You don’t want a loop to repeat forever. That’s called an infinite loop. The loops you write (if you write them properly, and of course you will) should come to a conclusion when they finish doing the job you set them up to do.
Why would you want a program to loop? The answer becomes clear when you think about the advantage of using a computer ...
Get Absolute Beginner’s Guide to C, 2nd Edition now with O’Reilly online learning.
O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.