निम्नलिखित स्यूडोकोड का आउटपुट क्या होगा, जहां ^ XOR ऑपरेशन का प्रतिनिधित्व करता है?
What will be the output of the following pseudocode, where ^ represent XOR operation?
Integer a, b, c
Set b=5,a=1
c=a^b
print c A
4
B
5
C
3
D
7
Explanation
Sure! Here's a quick explanation:
- a = 1 in binary:
0001 - b = 5 in binary:
0101
XOR operation (^) compares bits:
- 0 ^ 0 = 0
- 0 ^ 1 = 1
- 1 ^ 0 = 1
- 1 ^ 1 = 0
When we XOR 0001 and 0101, the result is 0100, which is 4 in decimal.
Thus, the output is 4.
Answer: (A) 4.
Correct Answer: A) 4