Wap to swap two values without using third variable

/*Wap to swap two values without using third variable*/

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter 2 value");
scanf("%d %d",&a,&b);
printf("before swapping\na=%d\nb=%d\n",a,b);
a=a+b;
b=a-b;
a=a-b;
printf("after swapping \na=%d,\nb=%d",a,b);
getch();
}

No comments:

Post a Comment