C++ program to swap two numbers using temporary variable

C++ program to swap two numbers using temporary variable. This program will change the numbers position using the C++. Swapping the numbers means it will interchange the number which are allocated in the c++ programming language.

#include <iostream>
using namespace std;
int main()
{
int a = 50, b = 10, temp,c;
cout << "Before" << c;
cout << "a = " << a << ", b = " << b << c;
temp = a;
a = b;
b = temp;
cout << "\nAfter" << c;
cout << "a = " << a << ", b = " << b << c;
return 0;
}

Output:

Before a = 50, b = 10
After a = 10, b = 50