Here is a C++ program to illustrate function returning pointer
SOURCE CODE OUTPUT
#include<iostream>
using namespace std;
int *func(int *p,int *q)
{
return *p>*q?p:q;
}
int main()
{
int x,y,*res;
cout<<"Enter two number ";
cin>>x>>y;
res=func(&x,&y);
cout<<"Greater of two number is : "<<*res;
return 0;
}
using namespace std;
int *func(int *p,int *q)
{
return *p>*q?p:q;
}
int main()
{
int x,y,*res;
cout<<"Enter two number ";
cin>>x>>y;
res=func(&x,&y);
cout<<"Greater of two number is : "<<*res;
return 0;
}
Any questions regarding to program please write in comments.
No comments:
Post a Comment