O'Reilly logo

C Programming Absolute Beginner’s Guide, Third Edition by Dean Miller, Greg Perry

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

14. Code Repeat—Using Loops to Save Time and Effort

In This Chapter

Saving time by looping through code

Using while

Using do...while

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 for tasks that people wouldn’t want to do. Computers never get bored, so you should give them mundane and repetitive ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required