What will be the output of the given code?
void main()
{
int i=1;
i=!i>2;
printf ("i=%d",i);
}
Ans: 0
Reason:
!1 will be 0 [Because of precedence of operator, ! Operator has more precedence than the > operator]
0 is compared with 2
Condition greater than fails
So the value of i will be 0
void main()
{
int i=1;
i=!i>2;
printf ("i=%d",i);
}
Ans: 0
Reason:
!1 will be 0 [Because of precedence of operator, ! Operator has more precedence than the > operator]
0 is compared with 2
Condition greater than fails
So the value of i will be 0
No comments:
Post a Comment