Basic Program 3

Write a program to demonstrate the use of returning a reference variable.



#include<iostream>
using namespace std;
int &max(int a, int b)
{
if(a>b)
return(a);
else
return(b);
}
void main()
{
int a1,b1;
cout<<"\n Enter value of a1 and b1 ";
cin>>a1>>b1;
int &ans=max(a1,b1);
cout<<"\n Maximum is "<<ans;
}