Thursday, March 7, 2013

Swapping two numbers


Write a program swapping two numbers.

#include <iostream.h>
#include <conio.h>
void main()
{
int a,b;
cout<<"Ener value for a: ";
cin>>a;
cout<<"Enter value for b: ";
cin>>b;
a=a+b;
b=a-b;
a=a-b;
cout<<"Value of a: "<<a<<"\n""Value of b: "<<b;
getch();
}

No comments:

Post a Comment