Home / Programs / Nested For Loop in C
Programming Example

Nested For Loop in C

👁 1,274 Views
💻 Practical Program
📘 Step by Step Learning
Nested for loop in c programming language

Program Code

#include <stdio.h>
int main()
{
	int i, j;
   for (i=0; i<2; i++)
   {
	for (j=0; j<4; j++)
	{
	   printf("%d, %d\n",i ,j);
	}
   }
   return 0;
}

Output

0, 0
0, 1
0, 2
0, 3
1, 0
1, 1
1, 2
1, 3
Press any key to continue . . .

Explanation

Nested for loop in c programming language

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.