C++ Program to swap two numbers using temporary variable [DEVCPP/GCC]


//Program to swap two numbers using temporary variable

#include<iostream>

using namespace std;

int main()
{

int a,b,temp;

cout<<"ENTER THE VALUE OF a:";
cin>>a;
cout<<"ENTER THE VALUE OF b:";
cin>>b;
cout<<"BEFORE SWAPPING:"<<endl<<"a="<<a<<" "<<"b="<<b<<endl;

temp=a;
a=b;
b=temp;

cout<<"AFTER SWAPPING:"<<endl<<"a="<<a<<" "<<"b="<<b<<endl;
       return 0;

}



Share this

Related Posts

FIND US ON FACEBOOK!