I want to integrate 2 simple code given below to make single workable code, the new code be like when we enter 2 different values in terminal then we get larger integer, thank you

1st Code :

#include
using namespace std;

int max(int first, int second){
return(first>second) ? first: second;
}
int main(){
int larger=max(1,2) ;
cout<<larger;
return 0;
}

2nd code:

#include
using namespace std;
int main(){

cout<<"Enter two integers x and y: ";
double first;
double second;
cin>>first;
cin>>second;
cout<<first+second;
return 0;
}

Create a header file and save your function(s) in that file. Demonstrated in C++ Part 3: Classes.

I not understand what you telling

Look here:

https://cplusplus.com/articles/Gw6AC542/

It is also explained in Part 3 of the C++ course.

1 Like