If-statement with logical OR
Posted
by exiter2000
on Stack Overflow
See other posts from Stack Overflow
or by exiter2000
Published on 2010-04-02T15:24:09Z
Indexed on
2010/04/02
15:33 UTC
Read the original article
Hit count: 256
programming-languages
public class Test{
public static void main(String args[]){
int a = 0;
int b = 1;
int c = 10;
if ( a == 0 || b++ == c ){
a = b + c;
}else{
b = a + c;
}
System.out.println("a: " + a + ",b: " + b + ",c: " + c);
}
}
Ok, this is Java code and the output is a: 11,b: 1,c: 10 And I believe the C acts same as Java in this case
That is because second condition(b++ == c) would never executed if the first condition is true in 'OR' operator.
There is a "NAME" for this. I just don't remember what it is. Does anyone know what this is called??
Thanks in advance
© Stack Overflow or respective owner