Related codes are those codes where similar programming concepts are in use. They are different from alternate codes in the sense that they may not have same purpose and results.

:

Run Output

x-y= 7
y-x = -7

Notes

int &min(int &a, int &b) if (a<b) return a; else return b;
Returns reference to a or b whichever is lower by its value content.

int x=2,y=3; min(x,y)=10;
Left side is supposed to be a function, since the function returns a reference of memory location it has been placed on left side. The returned reference will be filled with value 10. In this case x is lower so x will be filled with 10.

cout<<“x-y = “<<(x-y)<<endl;
Since x is now 10 and y is 3 so this will print 7.
cout<<“y-x = “<<(y-x)<<endl;
Since y is 3 and x is 10 so this will print -7.