Sometimes we see that a loop is written inside body of another loop-
for( i = 1 ; i <= n ; i++)
{
for( j = 1 ; j <= n ; j++)
{
........
........
}
}
It is called nesting of loops. Any type of loop can be nested inside any other type of loop.
Consider a pattern -
*
* *
* * *
For this we can write a C code as :
for( i = 1 ; i <= 3 ; i++)
{
for( j = 1 ; j <= i ; j++)
{
printf("* ");
}
printf("\n");
}
0 Comments