Question: c++ Write a function numberDigits that reads an integer and prints how many digits the number has, by checking whether the number is 10, 100,
c++
Write a function numberDigits that reads an integer and prints how many digits the number has, by checking whether the number is 10, 100, and so on. (Assume that all integers are less than ten billion.) If the number is negative, first multiply it with -1.
- Your function should be named numberDigits
- Your function takes one input parameter: an integer number
- Your function does not have a return value
- Your function prints number of digits in the format specified below
The format of the output should be "The number "
Example output:
If the function is called with 0 as the input argument:
The number 0 has 1 digit.
Note: You do not need to write the main(), the include, or namespace commands, you only need to write the function definition.
For example:
| Test | Result |
|---|---|
numberDigits(0); | The number 0 has 1 digits. |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
