Can any one explain why c still equal 15 after execution
int main(void)
{
int t,a=5,b=10,c=15;
t= ++a||++c;
printf("%d %d %d",t,a,c);
}
Can any one explain why c still equal 15 after execution
int main(void)
{
int t,a=5,b=10,c=15;
t= ++a||++c;
printf("%d %d %d",t,a,c);
}
The logical-or operator ||
is a short-circuit operator. If the left side evaluates to a true boolean value (i.e. not 0), then the right side doesn't execute.
Similarly for the logical-and operator &&
, if the left hand side is false (i.e. 0) the right hand side does not execute.