Site icon T4Tutorials.com

Swapping Program in C++ (C Plus Plus)

Swapping Program in C++ (C Plus Plus)

In this latest tutorial, we will cover the Swapping Program in C++ (C Plus Plus).

#include <iostream>
using namespace std;
int main()
{
int x,y,temp;
cout<<"Enter VAlue of X is ";
cin>>x;
cout<<"Enter Value of Y is ";
cin>>y;
cout<<"Value of X and Y is "<<x<<"\tand\t"<<y<<endl;
temp=x;
x=y;
y=temp;
cout<<"Value of x and y after swapping "<<x<<"\tand\t"<<y<<endl;
}

Output:


Video Lecture

Exit mobile version