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).

logic of swaping programExplanation of Swapping Program in C++ with three variables

#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:


Before and after swapping Program in C++ (C Plus Plus)

Video Lecture

Prof.Fazal Rehman Shamil (Available for Professional Discussions)
1. Message on Facebook page for discussions,
2. Video lectures on Youtube
3. Email is only for Advertisement/business enquiries.