Answers for "swap function in c++ swap by reference"

C++
3

C++ Swap Function

int a, b;

    cout << "Input first number: ";
    cin >> a;
    cout << "Input second number: ";
    cin >> b;

    swap (a, b);

    cout << "After swapping the first number: " << a << endl;
    cout << "After swapping the second number: " << b << endl;
Posted by: Guest on March-13-2022

Browse Popular Code Answers by Language