From 3975e8aa07d93c06039a21f3de630e3ce72315aa Mon Sep 17 00:00:00 2001 From: Tuhin114 Date: Thu, 5 Oct 2023 17:13:41 +0530 Subject: [PATCH] Swapping --- C++/swapping XOR.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 C++/swapping XOR.cpp diff --git a/C++/swapping XOR.cpp b/C++/swapping XOR.cpp new file mode 100644 index 00000000..2356ad9f --- /dev/null +++ b/C++/swapping XOR.cpp @@ -0,0 +1,23 @@ +#include + +int main() { + int a, b; + + std::cout << "Enter the first number (a): "; + std::cin >> a; + + std::cout << "Enter the second number (b): "; + std::cin >> b; + + std::cout << "Before swapping:" << std::endl; + std::cout << "a = " << a << ", b = " << b << std::endl; + + a = a ^ b; + b = a ^ b; + a = a ^ b; + + std::cout << "After swapping:" << std::endl; + std::cout << "a = " << a << ", b = " << b << std::endl; + + return 0; +}