Others have already mentioned that the comma operator returns the rightmost value. If you want to print the value, if ANY of these variables are true, use boolean or:
int main() { int a=10,b=20; char x=1,y=0; if(a || b || x || y) { printf("EXAM"); } }
But then keep in mind that the comma evaluates all expressions, while the statement or stops as soon as the value is true. So,
int a = 1; int b; if(a || b = 1) { ... }
b is undefined, whereas
int a = 1; int b; if(a, b = 1) { ... }
b will be set to 1.
source share