nested for loop


Loop inside a Loop is called nested for Loop.
Syntax:-
    for(exp 1; exp 2; exp 3)
  {
   for (exp1; exp2; exp3)
   {
   statement ……………………
   }
 }

W.A.P to print the numbers:-

#include<stdio.h>
#include<conio.h>
void main()
 {
  int i , j;
  for(j=1;j<=3;j++)
 {
  for(i = 1; i <=3 ; i++)
 {
  printf(“%d”, j );
 }
  printf(“\n”);
 }
  getch();
}

Output

1 2 3
1 2 3
1 2 3