Returning a reference variable.
CODING:
#include<iostream.h>
#include<conio.h>
int &max(int &a,int &b,int &c)
{
if(a>b && a>c)
return a;
else if(b>c)
return b;
else
return c;
}
void main()
{
int a,b,c;
clrscr();
cout<<"Enter No.";
cin>>a;
cout<<"Enter No.";
cin>>b;
cout<<"Enter No.";
cin>>c;
cout<<"Maximum Number:"<<max(a,b,c);
getch();
}
CODING:
#include<iostream.h>
#include<conio.h>
int &max(int &a,int &b,int &c)
{
if(a>b && a>c)
return a;
else if(b>c)
return b;
else
return c;
}
void main()
{
int a,b,c;
clrscr();
cout<<"Enter No.";
cin>>a;
cout<<"Enter No.";
cin>>b;
cout<<"Enter No.";
cin>>c;
cout<<"Maximum Number:"<<max(a,b,c);
getch();
}
Comments
Post a Comment