Question:What will be output when you will execute following c code?#include<stdio.h>
void main(){
int x=1,y=2;
if(--x && --y)
printf("x=%d y=%d",x,y);
else
printf("%d %d",x,y);
}
Choose all that apply:
+ ExplanationConsider the following expression:
--x && --y
In this expression && is Logical AND operator. Two important properties of this operator are:
Property 1:
(Expression1) && (Expression2)
&& operator returns 1 if and only if both expressions return a non-zero value other wise it && operator returns 0.
Property 2:
To optimize the execution time there is rule, Expression2 will only evaluate if and only if Expression1 return a non-zero value.
In this program initial value of x is 1. So –x will be zero. Since -–x is returning zero so -–y will not execute and if condition will be false. Hence else part will be executed.