What is Nesting of For Loops?

Nesting of loops, i.e., one for statement with in another for statement is allowed in C. For ex:–two loops can be nested as follows.

nested for loops


The nesting may continue up to any desired levels. The loops should be properly indented so as to enable the reader to easily determine which statements are contained with n each for statement.

ANSI C allows up to 15 levels of nesting.

Ex:–

#include<stdio.h>
#include<conio.h>
#define COLMAX 10
#define ROWMAX10
main()
{
Int row, column, y;
printf(“MULTIPLICATION TABLE\N”);
printf(“\n-------------------------------\n”);
for(row=1;row<=ROWMAX;++row)
{
for(column=1;column<=COLMAX;++column)
{
y=row*column;
printf(“%4d”,y);
printf(“\n”);
}
printf(“\n-------------------------------\n”);
}
grtch();
}


Related

C Language 3968148877868524675

Post a Comment

emo-but-icon

item