From ad31689f3b6fccd61e7f54355baaee40cb264d20 Mon Sep 17 00:00:00 2001 From: Sidddharthh <56505365+Sidddharthh@users.noreply.github.com> Date: Thu, 31 Oct 2019 06:47:43 +0530 Subject: [PATCH] swapping 2 values without using a 3rd variable --- swap_the_2_numbers_without_3rd_var.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 swap_the_2_numbers_without_3rd_var.c diff --git a/swap_the_2_numbers_without_3rd_var.c b/swap_the_2_numbers_without_3rd_var.c new file mode 100644 index 0000000..08321aa --- /dev/null +++ b/swap_the_2_numbers_without_3rd_var.c @@ -0,0 +1,16 @@ +#include +int main () { +int a,b; + + printf ("enter the value of num1 and num2 :"); + scanf ("%d %d", &a , &b ); + + a = a + b ; + b = a - b ; + a = a - b ; + + printf ("After swapping value of a : %d " , a); + printf ("After swapping value of b : %d ", b); + + return 0; + }