Program 13:
#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); }Explanation:
- Here we initialized a,b,c
- a---> for storing 1st number
- b--->for storing second number
- Now here goes the logic(let us take a=1 and b=3)
- a=a+b, Therefore, a=1+3=4
- b=a-b, Therefore b=4-3=1
- a=a-b, Therefore a=4-1=3
- Now the values of a and b are 3 and 1
- The values of a and are printed.