Answer to Question #160986 in C++ for Ashes

Question #160986

Write a program in C++ to find the maximum number between two numbers using a pointer.

Test Data :

Input the first number : 5

Input the second number : 6

Expected Output :6 is the maximum number.


1
Expert's answer
2021-02-03T16:36:52-0500
#include<iostream>
using namespace std;
int main()  
{  int first,second,*f,*s;


f=&first;
s=&second;


    cout<<"Enter first number"<<endl;
    cin>>first;
      cout<<"Enter second number"<<endl;
    cin>>second;
    if(*f>*s){

        cout<<"Largest="<<*f<<" and smallest="<<*s<<endl;

    }else{
    
    

            cout<<"Largest="<<*s<<" and smallest="<<*f<<endl;
    
    }

    


return 0;  
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog