0
For(;;) logic with example
I can't understand how does it work in programming logic. Can anyone explain it with an example? I want to know please help.
6 Respostas
+ 4
A for loop has a place to initialize variables, a place for an ending condition and a place to change variables basically.
for(int i=1; i<=10; ++i) {
// Do stuff
}
i increases up to 11, and then the loop stops, because the condition is not true anymore.
f(;;) just means that you leave all slots empty. You create no values, don't change them - and, most important, you have no condition, so the loop doesn't know when to stop.
Which means it'll just run forever (or until there's a break).
+ 2
Exactly.
0
Do you mean for(;;) instead of if?
0
Yes sorry for mistake it will for(;;)
0
Oooooo you mean it will go for infinite loop right.
0
Thanks you got it.