netx_iit

swapping two value without third variable

Jul 23rd, 2020 (edited)
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.44 KB | None | 0 0
  1. /* swapping of two numbers without used of third variable*/
  2. #include<stdio.h>
  3. #include<conio.h>
  4. int main()
  5. {
  6.     int no1,no2;//variable declaration
  7.     printf("\nEnter No 1=");
  8.     scanf("%d",&no1);
  9.     printf("\nEnter No 2=");
  10.     scanf("%d",&no2);
  11.     printf("\n Before Swapping value of no1 and no2 is %d and %d",no1,no2);
  12.     no1=no1+no2;
  13.     no2=no1-no2;
  14.     no1=no1-no2;
  15.     printf("\n After Swapping value of no1 and no2 is %d and %d",no1,no2);
  16.     return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment