From 4f48ce85cebc47dc5381dd9175e0ceac3d0ec9ca Mon Sep 17 00:00:00 2001 From: vishnu-santhosh Date: Mon, 1 Nov 2021 11:26:36 +0530 Subject: [PATCH] [MINOR] Variable swap using xor Swap two variables using xor without a third variable --- Swap/SwapUsingXor.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Swap/SwapUsingXor.c diff --git a/Swap/SwapUsingXor.c b/Swap/SwapUsingXor.c new file mode 100644 index 0000000..72f01b3 --- /dev/null +++ b/Swap/SwapUsingXor.c @@ -0,0 +1,13 @@ +#include + +void main() +{ + int a,b; + printf("ENTER THE TWO NUMBERS: "); + scanf("%d%d",&a,&b); + printf("BEFORE SWAPPING: A: %d B:%d\n",a,b); + a=a^b; + b=a^b; + a=a^b; + printf("AFTER SWAPPING: A: %d B:%d\n",a,b); +}