Let $x$ be an integer which can take a value of $0$ or $1$. The statement
if (x == 0) x = 1; else x = 0;
is equivalent to which one of the following ?
Firstly, our requirement is for $x=1$ it makes '$0$' and for $x= 0$ it makes '$1$'
Let's consider options one by one:
So, Option (B) is correct.
option D,
as,
x=1%x
assigns remainder after dividing with 1 and hence x has to be 0 for getting remainder value anything other than 0.(as 1 divides every number>0 )
x=1%0
It will not give 1. "Divide by 0 exception"
why (D) is wrong?
?
if(x=0) x=1; else x=0;
$(D)$ x = 1% x
when x=0
x = 1%0
i.e.$x=\frac{1}{0}=\infty$
it does not give any remainder.
when x=1
x = 1%1
i.e.$x=\frac{1}{1}$
it gives remainder $= 0$.
Both cases are not satisfied. So, this is false.
Feedback for next edition (if ever there's...