Sunday, June 6, 2021

Program check the maximum and minimum number using pointers (POP) (162)

#include<iostream>

using  namespace std;

int main()

{

int num1,num2;

int *ptr1;

int *ptr2;

ptr1=&num1;

ptr2=&num2;

cout<<"please enter the first number:";

cin>>num1;

cout<<"please enter the second number:";

cin>>num2;

if(num1>num2)

{

cout<<"the maximum number is:"<<*ptr1;

}

else if(num2>num1)

{

cout<<"the maximun number is:"<<*ptr2;

}

else

{

cout<<"you entered the same numbers:";

}

} 

No comments:

Post a Comment