What us the output of following C program? <stdio.h> int main() { int a=10;…
What us the output of following C program?
<stdio.h>
int main() {
int a=10;
int b=5;
a=a^b;
b=a^b;
a=a^b;
printf("%d %d",a,b);
return 0;
}
Answer: A. 5 10 — The bitwise XOR operator can be used to swap two variables. The XOR of two numbers x and y returns a number which has all the bits as 1 wherever bits of x and…
- A.
5 10
- B.
15 5
- C.
50 2
- D.
10 5
Attempted by 600 students.
Show answer & explanation
Correct answer: A
The bitwise XOR operator can be used to swap two variables. The XOR of two numbers x and y returns a number which has all the bits as 1 wherever bits of x and y differ. For example, XOR of 10 (In Binary 1010) and 5 (In Binary 0101) is 1111 and XOR of 7 (0111) and 5 (0101) is (0010).
Loading lesson…