Question PSC-FUNC-0055
MediumWhat will be printed by the following pseudocode?
Function sumDigitsUntilOne(Integer n)
while (n >= 10)
Integer s = 0
while (n > 0)
s = s + n mod 10
n = n / 10
end while
n = s
end while
return n
End Function
Print sumDigitsUntilOne(987654)
- A.
9
- B.
3
- C.
Sign up free to see the answer and a step-by-step explanation.