Skip to content
Related Articles

Related Articles

Improve Article
C | Operators | Question 22
  • Difficulty Level : Easy
  • Last Updated : 18 Jan, 2014




#include<stdio.h>
int main()
{
  int a = 2,b = 5;
  a = a^b;
  b = b^a;
  printf("%d %d",a,b);
  return 0;
}

(A) 5 2
(B) 2 5
(C) 7 7
(D) 7 2


Answer: (D)

Explanation: ^ is bitwise xor operator.

a = 2 (10)
b = 5 (101)

a = a^b (10 ^ 101) = 7(111)
b = a^b (111 ^ 101) = 2(10)

Quiz of this Question

Want to learn from the best curated videos and practice problems, check out the C Foundation Course for Basic to Advanced C.
My Personal Notes arrow_drop_up
Recommended Articles
Page :