Question PSC-FUNC-0004
EasyWhat will be the output of the following pseudocode?
Function s(Integer n)
if (n == 0)
return 0
end if
return (n mod 10) + s(n / 10) // integer division
End Function
Print s(472)
- A.
274
- B.
7
- C.
Show answer and explanation
Answer: C
It adds the digits recursively: 2 + 7 + 4 = 13.