Programming
September 5, 2023GATE 2023
September 19, 2023Programming
Question 1
|
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?
x = 1 + x;
|
|
x = 1 – x;
|
|
x = x – 1;
|
|
x = 1 % x;
|
Question 1 Explanation:
x = 1 – x
For x = 0, it gives 1.
For x = 1, it gives 0.
For x = 0, it gives 1.
For x = 1, it gives 0.
Correct Answer: B
Question 1 Explanation:
x = 1 – x
For x = 0, it gives 1.
For x = 1, it gives 0.
For x = 0, it gives 1.
For x = 1, it gives 0.
Subscribe
Login
0 Comments