C - Run three loops together using single loop statement.
In this code we will learn how to run multiple loops under single loop statement, here we will take three loop counter variables and run loop with their loop counter variables.
C Code Snippet - Run Three (Multiple Loops) under Single Loop Statement
/*C - Run three loops together using single loop statement.*/
#include <stdio.h>
int main(){
//loop counters
int iLoop1,iLoop2,iLoop3;
for(iLoop1=1, iLoop2=101, iLoop3=201; iLoop1<=10; iLoop1++, iLoop2++, iLoop3++){
printf("iLoop1: %3d, iLoop2: %3d, iLoop3: %03d\n",iLoop1,iLoop2,iLoop3);
}
}
iLoop1: 1, iLoop2: 101, iLoop3: 201
iLoop1: 2, iLoop2: 102, iLoop3: 202
iLoop1: 3, iLoop2: 103, iLoop3: 203
iLoop1: 4, iLoop2: 104, iLoop3: 204
iLoop1: 5, iLoop2: 105, iLoop3: 205
iLoop1: 6, iLoop2: 106, iLoop3: 206
iLoop1: 7, iLoop2: 107, iLoop3: 207
iLoop1: 8, iLoop2: 108, iLoop3: 208
iLoop1: 9, iLoop2: 109, iLoop3: 209
iLoop1: 10, iLoop2: 110, iLoop3: 210