0

What is c++ for loop

11th Mar 2018, 7:40 AM
Kyle Rafael Rosales
Kyle Rafael Rosales - avatar
2 Answers
+ 1
Suppose you want to do a task repeatedly a number of times... So , instead of writing it so many times you can just write it once and enclose in a for loop...so, basically for loop is an iterator (repeater). It's syntax is : for(initialization ; condition ; update){ //Your task } The for loop continues to do a task (Your task) until the specified condition becomes false. Once the condition becomes false the for loop breaks (stops) Generally, a loop counter is initialized in the for loop and is updated every time after performing the task in for loop. Hope it helps! https://www.sololearn.com/learn/CPlusPlus/1616/
11th Mar 2018, 9:15 AM
Akshat Vira
Akshat Vira - avatar
0
This would execute 10 times: for (int i{0}; i != 10; ++i) { 
 }
11th Mar 2018, 8:29 AM
Timon Paßlick