Write a program using function call to compare two integers and return the larger integer to the main program.
#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;
}
Comments
Leave a comment