Skip to content

Commit

Permalink
swapping 2 values without using a 3rd variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidddharthh committed Oct 31, 2019
1 parent 556e67e commit ad31689
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions swap_the_2_numbers_without_3rd_var.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <stdio.h>
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;
}

0 comments on commit ad31689

Please sign in to comment.