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

15. Looking for Another Way to Create Loops

In This Chapter

Looking for another way to repeat code

Working with for

Another type of C loop is called the for loop. A for loop offers more control than while and do-while. With a for loop, you can specify exactly how many times you want to loop; with while loops, you must continue looping as long as a condition is true.

C programs have room for all three kinds of loops. Sometimes one loop fits one program’s requirements better than another. For example, if you wrote a program to handle customer orders as customers purchase items from the inventory, you would need to use a while loop. The program would process orders while customers came through the door. If 100 customers happened to buy things, ...

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