Skip to content
Related Articles

Related Articles

Improve Article

GATE | GATE-IT-2004 | Question 15

  • Difficulty Level : Medium
  • Last Updated : 19 Jun, 2019

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?
(A) x = 1 + x;
(B) x = 1 – x;
(C) x = x – 1;
(D) x = 1 % x;


Answer: (B)

Explanation: Consider (B): x=1-x as we need to have x value either 0 or 1.

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

Attention reader! Don’t stop learning now.  Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.

Learn all GATE CS concepts with Free Live Classes on our youtube channel.

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


Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :