&& (logical AND) Example : (x>5) && (y<5)
It returns true when both conditions are true.
|| (logical OR) Example : (x>=10) || (y>=10)
It returns true when at-least one of the condition is true
printf("\n%d , %d\n",x--,y--); // x=1 , y=1
So, this expression return 1 (at-least one of the condition is true)
printf("\n%d , %d\n",--x,--y); // x=0 , y=0
So, this expression return 0 (at-least one of the condition is true)
So, in the condition if
&&(--x || --y)) //y-- does not excuted
he just excute --x ,here x=0,y=1 (y=1 because if condition verified just x-- because of OR ||)
The output is : 0 2
Difference between if and else if :
for example :
first case :
if(x == 0) ... //if x = 0 this will work and skip the following else-if statements
else if(x == 1) ...//if x not equal to 0 and if x = 1 this will work and skip the following else-if statement
else if(x == 2) ...// if x not equal to 0 or 1 and if x = 2 the statement will execute
Second case :
if(x == 0) ...//if x = 0 this will work and check the following conditions also
if(x == 1) ...//regardless of the x == 0 check, this if condition is checked
if(x == 2) ...//regardless of the x == 0 and x == 1 check, this if condition is checked
For the first case: once an else if (or the first if) succeeds, none of the remaining else ifs or elses will be tested. However in the second case every if will be tested even if all of them (or one of them) succeeds.
In your code , the first if is correct ,so the else if & else does not excuted ,if you want to excute the three condition , you should be use if in all of your conditions