#include "iostream"
using namespace std;
void main() {
int var1 = 10, var2 = 20, temporary;
cout << "Before swapping." << endl;
cout << "var1 = " << var1 << ", var2 = " << var2 << endl;
temporary = var1;
var1 = var2;
var2 = temporary;
cout << "\nAfter swapping." << endl;
cout << "var1 = " << var1 << ", var2 = " << var2 << endl;
}
Output
using namespace std;
void main() {
int var1 = 10, var2 = 20, temporary;
cout << "Before swapping." << endl;
cout << "var1 = " << var1 << ", var2 = " << var2 << endl;
temporary = var1;
var1 = var2;
var2 = temporary;
cout << "\nAfter swapping." << endl;
cout << "var1 = " << var1 << ", var2 = " << var2 << endl;
}
Before swapping
var1 = 10, var2 = 20
After swapping
var1 = 20, var2 = 10
var1 = 10, var2 = 20
After swapping
var1 = 20, var2 = 10
0 Comments
if you have any doubt in programming concept please let me know