Count Digits in a Number
A council website asks for a reference number and has to tell the user how many digits they typed, because a reference is only valid at certain lengths. The reference arrives exactly as it was typed. A reference of 0 is written with one digit, so it counts as one.
Task: Read a reference and print how many digits it has.
Input
A single line holding one integer n, with 0 ≤ n ≤ 1,000,000,000. There is no sign and no decimal point. The form does not tidy what was typed, so the line may carry stray spaces before or after the digits; those are not part of the reference.
Output
One line holding a single integer — how many digits the reference has.
Example:
Input:
98765
Output:
5
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in