#include<iostream>
using namespace std;
void swap(int *x, int *y)
{
    int temp=*x;
    *x=*y;
    *y=temp;
    cout<<*x<<endl<<*y<<endl<<"Bro"<<endl;
}
int main()
{
    int a=10,b=5;
    swap(&a,&b);
    cout<<"HI"<<endl;
    cout<<a<<endl<<b<<endl;
    return 0;
}
and
#include<iostream>
using namespace std;
void swap(int &x, int &y)
{
    int temp=x;
    x=y;
    y=temp;
    cout<<x<<endl<<y<<endl<<"Bro"<<endl;
}
int main()
{
    int a=10,b=5;
    swap(a,b);
    cout<<"HI"<<endl;
    cout<<a<<endl<<b<<endl;
    return 0;
}
Both the codes do give the same output but i don't get the fact that if we are only passing only the variable, how do the addresses get swapped
 
     
    