0
Is condition is mandatory in for loop?
I mean for(i=1,0,i++) Loop will execute or not?
13 Answers
+ 2
What is an if-loop? Do you mean an if-statement? Or a for-loop? Or a while-loop?
Only the tag the programming language that is relevant to your question.
+ 1
Without condition it would loop forever, so no it is not valid.
+ 1
There is no such thing like "if loop", though by syntax I can tell it is a for loop. If it is a for loop, loop may not execute as data type of i is not specified
+ 1
I think 0 will not gonna happen this
+ 1
Try True in place of 0
+ 1
But itll happens in infinite loop
So you have to define condition somewhere to exit the loop
0
You mean Infinte loop??
0
zemiak even if you use if(true) it will be executed only once, it won't be in loop
0
No it is not.
And with 0 condition will be false and you loop will not even run
0
First, all semicolons are mandatory. Second, technically the condition is not mandatory. Third, when using 0 the code will run but it will return nothing because it executes 0 times. Also, if you use an empty condition your loop will run forever.
0
What you can use of you want an infinite loop is 1==1 or something like that. Infinite loops are sometimes used for he's and the like, specifically for waiting for user input. Hope that helps.
0
Although as some else mentioned, it might be simpler to use a while loop.
0
If you don't provide a condition in your loop .... then it will turn out to be an infinite loop!!!