C++

C++ Program to Swap Two Numbers

#include <iostream>
using namespace std;  
main()
{
    int a = 5, b = 10, temp;
    cout << "Before swapping." << endl;
    cout << "a = " << a << ", b = " << b << endl;
    temp = a;
    a = b;
    b = temp;
    cout << "\nAfter swapping." << endl;
    cout << "a = " << a << ", b = " << b << endl;

}

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button
Close
Close