Thursday, October 17, 2019

C++ program to Swap two numbers (Using extra variable)



Program 

#include<iostream>
using namespace std;

int main()
{
    int a = 105, b = 2;
    int temp;
    cout<<"Before swap "<<a<<" "<<b<<endl;
    temp = a;
    a = b;
    b =temp;

    cout<<"After swap "<<a<<" "<<b;

}

Video explanation


No comments:

Post a Comment