Which of the following is printed as a result of the call demo (1234) ? (a) 1441 (b) 3443 (c) 12344321 (d) 43211234?
Answers
Answered by
1
d-This has a recursive call which means that the method calls itself when (x / 10) is greater than or equal to zero. Each time the method is called it prints the remainder of the passed value divided by 10 and then calls the method again with the result of the integer division of the passed number by 10 (which throws away the decimal part). After the recursion stops by (x / 10) == 0 the method will print the remainder of the passed value divided by 10 again.
Similar questions