C Programming —Nested Loops

Rem
1 min readFeb 12, 2019

--

for loop

The for loop groups together initialization, condition and increment/decrement.

for (initialization; condition; increment) 
sequence

nested for loop

for ( init; condition; increment ) {

for ( init; condition; increment ) {
statement(s);
}
statement(s);
}

while loop

As long as the test condition is true, this construct continues to execute.

while (condition)
sequence

nested while loop

while(condition) {

while(condition) {
statement(s);
}
statement(s);
}

do while loop

Executes its sequence at least once and continues as long as the test condition is true.

do
sequence
while (condition);

nested do while loop

do {
statement(s);

do {
statement(s);
} while (condition);

} while (condition);

--

--