A

Admin • 833K Points
Coach

Q. What will be the output of the following code?

Code:
#include <stdio.h>
int main() {
int a = 10, b = 20;
a = a ^ b;
b = a ^ b;
a = a ^ b;
printf("%d %d", a, b);
return 0;
}
  • (A) 10 20
  • (B) 20 10
  • (C) 30 0
  • (D) 0 30
  • Correct Answer - Option(B)
  • Views: 28
  • Filed under category C Programming
  • Hashtags:

Explanation by: Admin

This code swaps a and b without using a temporary variable.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.