Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
For Loop | Introduction to Program Flow
C++ Introduction

For LoopFor Loop

The for loop is more complex than the other loops and consists of three parts. Structure of for loop:

  • Counter;
  • Exit condition;
  • Loop expression.
cpp

main.cpp

  • int counter = 0: iteration counter;
  • counter++: For each iteration, 1 will be added to the counter variable to mark the passage of the loop;
  • counter <= 5: loop termination condition. The loop will continue if the counter variable is less than or equal to 5.

How many iterations will this loop make?

Select the correct answer

Everything was clear?

Section 4. Chapter 6
course content

Course Content

C++ Introduction

For LoopFor Loop

The for loop is more complex than the other loops and consists of three parts. Structure of for loop:

  • Counter;
  • Exit condition;
  • Loop expression.
cpp

main.cpp

  • int counter = 0: iteration counter;
  • counter++: For each iteration, 1 will be added to the counter variable to mark the passage of the loop;
  • counter <= 5: loop termination condition. The loop will continue if the counter variable is less than or equal to 5.

How many iterations will this loop make?

Select the correct answer

Everything was clear?

Section 4. Chapter 6
some-alt