Friday, 2 November 2012

Swaping The Values With out Third Variable


//Enter values and get Swaped values of Numbers.....
#include <iostream>
using namespace std;
int main ()
{
int n1,n2;
cout << "Enter fist number:" <<endl;
cin >> n1;
cout << "Enter second number:" <<endl;
cin >> n2;
n1=n1+n2;
n2=n1-n2;
n1=n1-n2;
cout << "The value of first number after swap = "<< n1<<endl;
cout << "The value of second number after swap = " << n2<<endl;
return 0;
}

No comments:

Post a Comment