How to use nesting for loop in C language
Nesting Loop
On this page
Nesting Loop
Program to use Nesting For Loop in C language
#include <stdio.h>
int main()
{
int i, j;
for (i = 1; i <= 3; i++)
{
printf("i = %d\n", i);
for (j = 1; j <= 5; j++)
{
printf("j = %d\t", j);
}
printf("\n");
}
return 0;
}
Output
i = 1
j = 1 j = 2 j = 3 j = 4 j = 5
i = 2
j = 1 j = 2 j = 3 j = 4 j = 5
i = 3
j = 1 j = 2 j = 3 j = 4 j = 5