Wednesday 18 December 2013

TWO NUMBERS INTERCHANGE WITHOUT USING THE THIRD VARIABLE IN C++


#include<iostream.h>
#include<conio.h>
void main()
{
  clrscr();
  int a,b;
  cout<<"enter  the value of number 1 =”;
  cin>>a;
  cout<<"enter  the value of number 2";
  cin>>b;
  a=a+b;
  b=a-b;
  a=a-b;
 
  cout<<"\n"<<"after interchanging value of"<<" number 1 ="<<a<<"\n"<<" number  2="<<b;
  getch();
}
/*THIS PROGRAM ACCEPT TWO NUMBERS AS INPUT AND GENERATE TWO NUMBER IN OUTPUT BY     SWAPPING THEIR VALUES*/

No comments:

Post a Comment