Answer:
Following are the program in the C++ Programming Language:
#include <iostream> //header file
using namespace std; //namespace
int biggerDigits(int n, int m) { //define function
if (n <= 0 || m <= 0) { //set if statement
return 0;
}
else { //set else statement
int a,b; //set integer variables
a = n % 10; //perform modulatio
b = m % 10; //perform modulatio
int max = a; //set integer variable and assign value
if (b > max) //set if statement
max = b; //initialize value to max
/*solution is here*/
return 10 * biggerDigits(n / 10, m / 10) + max;
}
}
int main() // main method
{ // code is refer from question to make the program
cout << biggerDigits(567, 765) << endl; // call the function biggerdigits
cout << biggerDigits(123456, 444444) << endl; // call the function biggerdigits
//call function and print result
cout << biggerDigits(999, 111) << endl; // call the function biggerdigits
return 0; // return the integer 0
}
Step-by-step explanation:
Here, we set the header file "<iostream>" and namespace "std" then, we set a function "biggerDigits()" and pass two integer type arguments inside it.
- we set if condition in which when the variable "n" is less than equal to 0 or m is less than equal to 0 then, it return 0.
- we set the else statement inside it we set two integer type variables "a" and "b" then, perform modulation with both the variables.
- we set integer variable "max" and assign value of a in it.
- we set if condition in which we check when the variable b is greater than variable max then, initialize the value of variable b in the variable max and return the solution through recursion.