Question 2751
public static int digitCount(int n)
{
if (n < 10)
{
return 1;
}
return 1 + digitCount(n / 10);
}
What value is returned by the call digitCount(84263)?Main Solution
Solution:
Correct: C. Each recursive call strips the last digit (integer division by 10). digitCount(84263)=1+digitCount(8426)=2+digitCount(842)=3+digitCount(84)=4+digitCount(8)=4+1=5.
Answer: Correct: C
Answer images

