C++ program to find maximum of two numbers using pointers and functions



#include<iostream>

using namespace std;


void largest_num()

{

int x,y;

int *large,*p1,*p2;

cout<<"Enter Two Numbers:"<<endl;

cin>>x>>y;

p1 = &x;

p2 = &y;

if(*p1 > *p2)

{

large=p1;

}

else

{

large=p2;

}

cout<<"Largest Number Is:"<<*large<<endl;

}


int main()

{

    largest_num();

    

return 0;

}

No comments:

Post a Comment

Internet Celebrity Shaam Idrees & his wife Sehar aka Froggy decided to live separately

Famous YouTuber Sham Idris and his wife Sahar aka Froggy have decided to live separately for some time. Sham Idris informed his fans on soci...