C Program to Swap two no’s without using third variable
Program to show swap of two no’s without using third variable
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include<stdio.h> int main() { int a, b; printf("\nEnter value for num1 & num2 : "); scanf("%d %d", &a, &b); a = a + b; b = a - b; a = a - b; printf("\nAfter swapping value of a : %d", a); printf("\nAfter swapping value of b : %d", b); return (0); } |
Output :
1 2 3 4 | Enter value for num1 & num2 : 10 20 After swapping value of a : 20 After swapping value of b : 10 |