Brijmohan lal Sahu - Facebook
ads
ads

Saturday, November 15, 2014

Program to Swap two values with third variable in C++.


Swapping


Code Box
---------------------------------------------

/*program to swap two values using third variable */

#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,temp;
clrscr();

cout<<"\nEnter two numbers :";
cout<<"\nEnter first number a= ";
cin>>a;

cout<<"\nEnter second number b= ";
cin>>b;

cout<<"\nValues before swapping a= "<<a<<" & b= "<<b;

temp=a;   //swapping
a=b;
b=temp;

cout<<"\n\nValues after swapping a= "<<a<<" & b= "<<b;

getch();
}

No comments:

Post a Comment