From the course: C Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Creating a for loop

Creating a for loop - C Tutorial

From the course: C Essential Training

Start my 1-month free trial

Creating a for loop

- [Instructor] Along with decision making, another way to control program flow is one of the basic concepts of computer programming, the loop. A loop is one or more statements that repeat. The loop's condition determines how many times the statements repeat. Three C language keywords deal with loops, for, while and do. Loops feature three parts, a starting condition or initialization, an expression that must remain true for the statements to repeat and an exit condition to terminate the loop. In a for loop, all three conditions are expressed in the keywords parentheses as shown in this exercise file. The starting condition or a loop initialization appears first. Variable a is initialized to zero. A semi-colon separates the expressions in a for statement. Next comes the condition. The loop repeats as long as the value of variable a is less than 10, then comes another semi-colon, and then finally the expression…

Contents