Example of C part 7 swap two no. without using 3 variable
SWAP TWO NUMBER
PROGRAM :
Output:
Enter a
30
Enter b
35
The values of a is 30 and b is 35 before swaping
The values of a is 35 and b is 30 after swaping
PROGRAM :
#include<stdio.h> main() { int a,b; printf("Enter a\n"); scanf("%d",&a); printf("Enter b\n"); scanf("%d",&b); printf("The values of a is %d and b is %d before swaping\n",a,b); a=a+b; b=a-b; a=a-b; printf("The values of a is %d and b is %d after swaping\n",a,b); }
Enter a
30
Enter b
35
The values of a is 30 and b is 35 before swaping
The values of a is 35 and b is 30 after swaping