Count Digits in a Number
Count Digits in a Number
Tags: Basics
Credit: CodingChallenge
Difficulty: Beginner
Type: Text
Category: Practice
Time Allowed: 5 s
Description:
Write a function that takes a positive integer N and returns the number of digits it contains using a while loop. This problem is designed to help you practice using while loops and working with numbers
. The function should accept one parameter and return the count of digits.
Constraints:
- The input will be a positive
integer
greater than zero. - The function should
return
aninteger
representing the number of digits.
Example:
- Input:
12345
- Output:
5
Test Case | Input | Expected Output |
---|---|---|
1 | 1 | 1 |
2 | 12345 | 5 |
3 | 1000 | 4 |
4 | 9876543210 | 10 |
Leave a Comment
Please login to leave a comment.