Advertisement
Tahamina_Taha

Swap Numbers without Temporary Variable

Aug 17th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.37 KB | None | 0 0
  1. #include<stdio.h>
  2. void main()
  3. // Swap Numbers without  Temporary Variable
  4. {
  5.  
  6.     double a,b;
  7.     printf("Enter first number:\n");
  8.     scanf("%lf",&a);
  9.     printf("Enter second number:\n");
  10.     scanf("%lf",&b);
  11.     a=a-b;
  12.     b=a+b;
  13.     a=b-a;
  14.     printf("After swapping, first Number: %.0lf\n",a);
  15.     printf("After swapping, second Number: %.0lf",b);
  16.  
  17.  
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement