Nested Do while Loop with 4 Levels
Nested Do while Loop with 4 Levels
This program is a javascript program using 4 levels nested do while loop to solve a program. It contains 4 levels nested do while loop.
Algorithm of Nested Do while Loop with 4 Levels
The algorithm is a step by step procedure to solve a procedure. Let’s see the algorithm to solve the mentioned problem.
- Start
- Declare Variables
- start outer loop
- start inner loops
- print output ” **”
- increment the variable in every loop.
- Stop
Pseudo Code of Nested Do while Loop with 4 Levels
- tag <script>
- Declare & initialize var i
- Declare & initialize var j
- Declare & initialize var k
- Declare & initialize var l
- go to inner loop print ” **”
- print “\n”
- increment l++;
- check l<2
- print ” **”
- print “\n”
- l++
- check condition false.
- out of loop
- k++;
- check k<2;
- print ” **”
- print “\n”
- k++;
- condition k<2 false
- out of loop
- j++;
- check j<2 true
- print ” **”
- print “\n”
- j++
- condition j<2 false
- out of loop
- i++
- condition i++ true
- print ” **”
- print “\n”
- i++
- condition i<2 false
- out of loop
Program of Nested Do while Loop with 4 Levels
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
<script> var i =0; var j =0; var k=0; var l=0; do{ do{ do{ do{ document.write(" **"); document.write("\n"); l++; }while(l<2) k++; }while(k<2) j++; }while(j<2) i++; }while(i<2) </script> |