Create a free account on Computer Sir Ki Class and unlock access to valuable learning resources.
Exam Paper Downloads: After registering and logging in, you can download exam question papers in PDF format to practice and prepare for your exams.
Student Support: Get assistance with your doubts, queries, and questions related to your studies. Our support is here to help you understand topics and resolve your learning difficulties.
Register today and make your exam preparation easier and more effective!
#include
using namespace std;
int &min(int &a, int &b)
{
if (a
×
Ask AI About This Code
Default Prompt that is passed along with the code is given below, You can write your own prompt if you so desire.
×
Test CPP
The code has been copied automatically for you in the clipboard. After that open any of the service and press cntrl-v to paste in the given code area. Needs a bit of tweaking as per the link.
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.