Back to C Notes
Topic #44

Nested Loops


Nested Loops

It is also possible to place a loop inside another loop. This is called a nested loop.

The "inner loop" will be executed one time for each iteration of the "outer loop":

Example

int i, j;

// Outer loop
for (i = 1; i <= 2; ++i) {
  printf("Outer:
%d\n", i);  // Executes 2 times

  // Inner loop
  for (j = 1; j <= 3; ++j) {

printf(" Inner: %d\n", j);  // Executes 6 times (2 * 3)
  }
}

Multiplication Table Example

This example uses nested loops to print a simple multiplication table (1 to 3):

Example

int i, j;

for (i = 1; i <= 3; i++) {
  for (j = 1; j <= 3; j++) {
    printf("%d ", i * j);
  }
  printf("\n");
}

Nested loops are useful when working with tables, matrices, or multi-dimensional data structures.

Want to go beyond the notes?

Join Coding Now Tech Institute's C course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Nested Loops – FAQs

Quick answers about learning Nested Loops in C.

This free note from Coding Now Tech Institute explains Nested Loops in C — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every C topic on Coding Now Tech Institute, including Nested Loops, is 100% free with no signup required.
With focused practice, most students grasp Nested Loops in 1–3 days from these notes; pairing it with Coding Now Tech Institute's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the Coding Now Tech Institute Community (/community) — expert instructors answer within 24 hours.
Call NowEnroll Now