Monday, February 16, 2015

C program to swap two numbers without using temp variable

#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();
int a,b;
cout<<"Enter value of a:";
cin>>a;
cout<<"Enter value of b:";
cin>>b;

a=a+b;
b=a-b;
a=a-b;

cout<<"
a="<<a;

cout<<"
b="<<b;

getch();
}