Nested Loops in C – C allows loops to be nested, that is, one loop may be inside another. The program given below illustrates the nesting of loops. Let us consider a program to illustrate nested loops.
Program to generate the following pattern given below
1 2 3
1 2 3 4
/* Program to print the pattern */
Here, an inner for loop is written inside the outer for loop. For every value of i, j takes the value from 1 to i and then value of i is incremented and next iteration of outer loop starts ranging j value from 1 to i.