- 2
Is this a valid statement?If valid, plzz explain how the loop will execute?
while (a<4,i>10)
6 odpowiedzi
+ 1
What programming language is it? And what should it do?
+ 1
I do not know c++ but I suppose conditions should be joined by logical operators, not by comma
+ 1
you could put many statements comma separated, but only the result of the last (right most) statement will be used to evaluate the condition result (in your example, the while loop will break only if i<=10, the first statement will not have effect on the loop condition)
0
If you are considering Python, it is indeed a valid loop. However, it is an infinite loop, because the condition will always be True, regardless the values of a and i.
This is because you put a tuple as argument and it always returns True unless it's empty. Since it is never empty, the loop will run forever.
Consider changing the comma to a logical operator, like "and" or "or". Then see what happens :)
0
Lisa it is c++ I am just asking that can we put the conditions like that (separated by commas)
0
visph thanks