Nested Loops



If a loop is used within a loop then such a control structure is called nested loop.

Ex:-
  for (------------)
    {
      for (------------)
        ----
        ----
        ----
    }

Nested loop are used to repeatedly execute a block of code is itself repeating some code.

Flow chart for nested loop
nested loop

Continue statement

  • During loop operations it may be necessary to skip a part of the body of the loop under certain conditions.
  • Like the break statement C supports similar statement called continue statement.
  • The continue statement causes the loop to be continued with the next iteration after skipping any statement in between.
  • The format of the continue statement is simply:

Compare break and continue statement

Break Statement Continue statement
The break statement is used to break the control in the loops or in the general statements it is used to break the sequence. The continue statement is used to transfer the control in the beginning of loop.
A break within a loop should always be protected within an if statement which provides the test to control the exit condition. Continue should be protected by an if statement.