If condition and assign value in c/c++

void main()
{
if(a=0)
printf(“a is zero”);
else
printf(“a is not zero”);
}

Tutorial answer:
a is not zero
Debugging solution:
Normally you think ans is a is zero but not because if condition it contain only one equivalent= operand not double(==) ,so it will assign a is zero,if(a)=if(0),finally if condition become false so it execute else condition.

Post a Comment

0 Comments