Monday, October 1, 2012

C++ - Swap two numbers using three variables

#include<iostream.h>
#include<conio.h>
int main(void)
{
   int x,y,z;
   cout<<"\nEnter First Number : ";
   cin>>x;
   cout<<"\nEnter Second Number : ";
   cin>>y;
   z=x;
   x=y;
   y=z;
   cout<<"\n\nAfter Swapping\n\nFirst Number : "<<x<<"\nSecond Number : "<<y;
   return 0;
}

0 comments:

Post a Comment