Ask Question
16 November, 18:25

Write a function digits () that accepts a non-negative integer argument n and returns the number of digits in it's decimal representation. For credit, you should implement this using a loop and repeated integer division; you should not use math. log (), math. log10 (), or conversion to string

+2
Answers (1)
  1. 16 November, 20:54
    0
    Let do this in python. We will utilize the while loop and keep on dividing by 10 until that number is less than 10. Along the loop we will count the number of looping process. Once the loop ends, we can output that as answer.

    def digits (n):

    n_digit = 1

    while n > = 10:

    n_digit + = 1

    n / = 10

    return n_digit
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a function digits () that accepts a non-negative integer argument n and returns the number of digits in it's decimal representation. ...” in 📙 Engineering if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers