C Basic Programms
C Basic Programms
#include<stdio.h>
int main()
{
int a=10,b=20,c;
printf("Before swapping a=%d and b=%d\n",a,b);
c=a;
a=b;
b=c;
printf("After swapping a=%d and b=%d\n",a,b);
}
13. Method3: Swapping without using third variable
#include<stdio.h>
int main()
{
int a=10,b=20,c;
printf("Before swapping a=%d and b=%d\n",a,b);
c=a+b;
a=c-a;
b=c-b;
printf("After swapping a=%d and b=%d\n",a,b);
}
int main()
{
int a=10,b=20;
printf("Before swapping a=%d and b=%d\n",a,b);
a=a+b;
b=a-b;
a=a-b;
printf("After swapping a=%d and b=%d\n",a,b);
}