ADVERTISEMENT
ADVERTISEMENT

C - Run three loops together using single loop statement.


IncludeHelp 03 July 2016

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

ADVERTISEMENT




ADVERTISEMENT



Comments and Discussions!

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.