Consider the method below, which prints the digits of an arbitrary positive integer in reverse order, one digit per line. The method should print the last digit first. Then, it should recursively print the integer obtained by removing the last digit. Select the statements that should be used to complete the method. public static void printReverse(int value) { if (value > 0) { _____________________ // print last digit _____________________ // recursive call to print value without last digit } }

Respuesta :

Answer:

System.out.println(value % 10);

printReverse(value / 10);

Explanation:

System.out.println(value % 10);

To print the last digit, we print the value modulo 10 as the result of the value modulo 10 gives us the last digit.

printReverse(value / 10);

To call the recursive method again without the last digit, we now pass the result of dividing the value with 10 inside the printReverse method as parameter. The division by 10 will remove the last digit from the value and result will be the remaining digits.