Hi! After seeing For Beginners In C Topic, I thought to contribute all the loops syntax! so here we go.... FOR LOOP SYNTAX Code: for(initial condition; checking condition; increment) { statement } for example. Code: for(i=0;i<=10;i++) { conunt = count + i; }
Thanks Pankaj! ---------------------- Now I'm going to describe do-while loop! This loop is usually used to work on a single codition, such as "Add 1 with x if x greater than 5" etc. This loop is called "Exit Controlled" loop. Syntas: Code: do { statement; } while { Statement; } In this loop, if you look at the structure, you will find that, while processing it will process the first step and then it will check the condition! That is why its called "Exit Controlled Loop"!
few looping practice Code: void main() { int i=5; while(i>5) { printf("Cfanatic.com"); } } o/p No output Code: void main() { int i=5; do { printf("Cfanatic.com"); }while(i>5); } o/p Cfanatic.com Code within do-while loop execute once whether condition is true or false.
Code: void main() { int i; for(i=0;i<100;i++); printf("Prashanna Bhoi"); } o/p Prashnna Bhoi once. this is called delay loop