DamnSchool
Like if statement for loop also nested. The loop within the loop is called nested loop. In nested for loops two or more for statements are included in the body of the loop. The number of iterations in this type of structure will be equal to the number of iterations in the outer loop multiplied by the number of iterations in the inner loop.

Nesting of for loops

#include<stdio.h>
int main()
{
int i,j;
for(i=1;i<=3;i++)
{printf("\n");
for(j=1;j<=3;j++)
{printf("%d\t",j);}
}
}

Run Example >

< Previous Next >

Privacy Policy Terms of Service About
Creative Commons License
This work is licensed under a Creative Commons Attribution-NoDerivatives 4.0 International License.