LATEST PROGRAMS

Write a Program in C++ to swap two numbers without using third variable.

#include<iostream.h>
using namespace std;

int main()
{
    int a, b;
    cout<<"Enter the two numbers :\n";
    cin>>a>>b;
    cout<<"Before swapping a =  "<<a<<" b = "<<b;
    a=a^b;
    b=a^b;
    a=a^b;
    cout<<"\n After swapping a =  "<<a<<" b = "<<b;
    return 0;
}
18/02/2023, 12:15 am Read : 132 times