Find out the larger no by return by refrence mechanism.
#include<iostream.h>
#include<conio.h>
int & large(int &,int &);//fun declaration
void main()
{
int a,b,y;
clrscr();
cout<<"\n Enter the First No:-";
cin>>a;
cout<<"\n Enter the second No:-";
cin>>b;
y=large(a,b);//fun call
if(y==1)
cout<<a<<"\n a is larger";
else
cout<<b<<"\n b is larger";
getch();
}
int &large (int &x,int &y)//fun def
{
if(x>y)
return x;
else
return y;
}
#include<iostream.h>
#include<conio.h>
int & large(int &,int &);//fun declaration
void main()
{
int a,b,y;
clrscr();
cout<<"\n Enter the First No:-";
cin>>a;
cout<<"\n Enter the second No:-";
cin>>b;
y=large(a,b);//fun call
if(y==1)
cout<<a<<"\n a is larger";
else
cout<<b<<"\n b is larger";
getch();
}
int &large (int &x,int &y)//fun def
{
if(x>y)
return x;
else
return y;
}