Skip to main content

Posts

Showing posts from June, 2021

Nesting of Loops

We can write one loop inside another loop.A loop within another loop is called a nested loop. In C programming, nested loops are loops that are placed inside another loop. This allows you to repeat a set of instructions multiple times, and inside each iteration of the outer loop, the inner loop completes its full iteration. Nested loops are useful when you need to perform repetitive tasks within repetitive tasks. The following is the syntax of writing one for loop inside another for loop.There is no rule that a loop must be nested inside its own type. In fact, there can be any type of loop nested inside any type and to any level. Each inner (nested) loop must be completely embedded within an outer loop, the loops cannot overlap.Here for each iteration of the outer loop, the inner loop keep executing completely. Nesting of for loop for ( initialization; condition; increment )  {       for ( initialization; condition; increment )       { // statement of inside loop       }       // state