Q.1>>Think about the output:
void main()
{
int x=100;
if(!!x)
printf("x=%d",x);
else
printf("x=%d",x);
}
which printf() do you find in the output?
ANS:
which ever printf() will execute, the o/p is same in both the cases.
But the main thing is to know about the (!!x) condition inside the if().
1st "!x" will make the value 0 which is assigned 100 that is 1 for a if statement.
The 2nd "!" will make it to 1 again.
so, the if() will be execute; not the else one.
But, remember the value of x will not change to 1 as it was changed in a condition statement.Its value remain 100.
No comments:
Post a Comment