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 ?

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 ? Correct Answer x =1 -x ;

Consider the option: x = 1 - x. Consider x = 0 ; x = 1 - 0 = 1 = > So when x = 0 we get x value to be 1. Consider x = 1 ; x = 1 - 1 = 0 = > So when x = 1 we get x value to be 0.

Related Questions

Consider the Question and two Statements given below : Question : Is x an integer? Statement-1 : x / 3 is not an integer. Statement-2 : 3x is an integer. Which one of the following is correct in respect of the Question and the Statements?