+ 1
What if we put two arguments in while loop condition seperated by' , ' in clanguage
3 Antworten
+ 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
+ 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