0
What is c++ for loop
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/
0
This would execute 10 times:
for (int i{0}; i != 10; ++i)
{
âŠ
}