Advertisement
Programmin-in-Python

C Program to swap 2 numbers without using temporary variable

Jan 6th, 2022
788
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.24 KB | None | 0 0
  1. #include <stdio.h>
  2. int main(){
  3.     int a, b;
  4.     printf("Enter the value of a : ");
  5.     scanf("%d", &a);
  6.     printf("Enter the value of b : ");
  7.     scanf("%d", &b);
  8.  
  9.     a = a+b;
  10.     b = a-b;
  11.     a = a-b;
  12.  
  13.     printf("a : %d\nb : %d", a, b);
  14.     return 0;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement