Arduino – nested loop

loop

C language allows you to use one loop inside another loop. The following example illustrates the concept.

nested loop Syntax

for ( initialize ;control; increment or decrement) {
   // statement block
   for ( initialize ;control; increment or decrement) {
      // statement block
   }
}

Example

for(counter = 0;counter <= 9;counter++) {
   //statements block will executed 10 times
   for(i = 0;i <= 99;i++) {
      //statements block will executed 100 times
   }
}

Previous Page:-Click Here

Leave a Reply