Answers for "swap integers in cpp"

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
-2

swap of two numbers in c++

#include<iostream>
using namespace std;
int main()
{
    
    int a,b;
    cin>>a>>b;
    swap(a,b);
    cout<<a<<" "<<b;
    return 0;
}
Posted by: Guest on October-20-2021

Browse Popular Code Answers by Language