+ 1

What if we put two arguments in while loop condition seperated by' , ' in clanguage

16th Feb 2019, 6:52 AM
Shakti Vishwakarma
Shakti Vishwakarma - avatar
3 ответов
+ 9
If you use comma as the separator of the expressions then only the expression following the last comma will be evaluated as loop condition, at least that's how I see from a quick test : ) #include <stdio.h> int main() { int a = 0, b = 1; // <a> is ignored, only <b> is evaluated // try with "while(b, a)" to see difference. while(a, b) { puts("Yes it works!"); break; // prevent infinite loop } return 0; } Hth, cmiiw
16th Feb 2019, 8:42 AM
Ipang
+ 7
it can be dont in two ways while(a<b&&c<b) {} while(a<b||a>c) {} In the above case its AND joint and in the other one its a OR joint
16th Feb 2019, 8:01 AM
Shahil Ahmed
Shahil Ahmed - avatar
16th Feb 2019, 8:01 AM
Gordon
Gordon - avatar