O'Reilly logo

C by Nikolaos D. Tselikas, George S. Tselikis

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

Chapter 6

Loops

Often, programs contain blocks of code to be executed more than once. A statement whose job is to repeatedly execute the same block of code as long as the value of a controlling expression is true is called an iteration loop. In this chapter, you’ll learn about C’s iteration statements: for, while, and do-while, which allow us to set up loops, as well as break, continue, and goto statements, which can be used to transfer control from one point of a program to another.

for Statement

for statement is one of C’s three loop statements. It is typically used when the number of iterations is predetermined. The general form of the for statement is:

for(init_exp; cond_exp; update_exp)
{
/* a block of statements (the loop body) that is ...

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