Write a program to Swap two numbers in C++ Language - Program to swap two numbers in C++

Program to Swap Two Numbers in C++ Language

#include <iostream>

using namespace std;

int main()

{

    int a = 0, b = 0, temp;

    cout << "Enter number a = ";

    cin >> a;

    cout << "Enter number b = ";

    cin >> b;

    cout << endl << "a = " << a << ", b = " << b << endl;

    temp = a;

    a = b;

    b = temp;

    cout << "\nAfter swapping." << endl;

    cout << endl << "a = " << a << ", b = " << b << endl;

    return 0;

}

इस कोड को हमने CODEBLOCK पर बना कर run किया है


OUTPUT


Comments