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
πŸ’¬ Discuss
βœ… Correct Answer: (B) 20 10
Explanation: This code swaps a and b without using a temporary variable.
Explanation by: Mr. Dubey
This code swaps a and b without using a temporary variable.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
63
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
80%
Success Rate