Assignments » Variable, Operator and Expression » Set1 » Solution 7

Write a program to swap the values of two variables.

    
#include<iostream>
using namespace std;

int main()
{
	int a,b,temp;
	cout<<"\nEnter two numbers : ";
	cin>>a>>b;
	temp=a; 
	a=b;
	b=temp;
	cout<<"\nAfter swapping numbers are : ";
	cout<<a<<" "<<b;

	
	return 0;
}

Enter two numbers : 78 6
After swapping numbers are : 6 78