Nested loop is a loop inside another loop, it is useful when you want to print numbers in rows and columns form like in 2d arrays or to print a pattern.
Example 1: Nested for loop.
for (i=1; i<=10; i++) { for (j=1; j<=10; j++) { printf("%d\n", a++); } }
Example 2: Nested while loop.
int i=1, j=1, a=1; while (i<=10) { while (j<=10) { printf("%d\n", a++); j++; } i++; }
Example 3: Nested do while loop.
int i=1, j=1, a=1; do{ do{ printf("%d\n", a++); j++; }while (j<=10); i++; }while (i<=10);