Nested loop in c++ with example

c allows for, while and do while loops to be nested. that is one loop is inside another loop.

Example:-


Output:-

.....
....
...
..
.

one type of loop can be nested with other type of loop. for example while loop is inside for loop.

Example:-



Previous Code:-
Do while loop

List Code:-
C++ Codes

Next Code:-
Switch case

C++ Programs
List of c++ Programs

5 Comments

  1. What are loops and how we can use them?

    In general a loop is a sequence of statements which is specified once but which may be carried out several times in succession. The function of the loop is to repeat the calculation a given number of times until it reaches a certain value. The code inside the loop is obeyed a specified number of times, or once for each of a collection of items, or until some condition is met, or indefinitely. We can divide loops into:
    1) Count-controlled loops,
    2) Condition – controlled loops,
    3) Collection - controlled loops,
    4) General iteration,
    5) Infinite loops,
    6) Continuation with the next iteration,
    7) Redo the current interation and
    8) Restart loop

    For more information please visit: http://megacplusplustutorials.blogspot.com

    ReplyDelete
  2. Hmm... Good one

    ReplyDelete
  3. The output of first question is wrong.. it should be like this -->

    ......
    .....
    ....
    ...
    ..
    .

    ReplyDelete

Add your comments here

Back to Top