Answer to Question #180814 in C++ for Darren

Question #180814

Write a program using function call to compare two integers and return the larger integer to the main program.



1
Expert's answer
2021-04-13T06:30:17-0400
#include<iostream>
using namespace std;
void greaterNumber(int a, int b){
if(a>b){
    cout<<a<<" is greater than "<<b<<endl;
}else{
cout<<b<<" is greater than "<<a<<endl;
}
}

int main(){
int x,y;
cout<<"Enter the value of first number"<<endl;
cin>>x;
cout<<"Enter the value of second number"<<endl;
cin>>y;
greaterNumber(x,y);

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
APPROVED BY CLIENTS