Written by Rubaiat
on
on
cpp program to count digits
Often programmers are faced with the task of counting digits for a number with some special phenomena. Like, how many digit’s there for the factorial of a number n in base b?? Here, the last part (factorial of n, in base b) represents the phenomena; for this specific attribute we need to count the number of digits present.
The simple task of counting digits for a given positive number can de done with the following cpp code. This code demonstrates a very simple approach, feel free to examine and modify the code in order to better understand it.
So, after you’ve determined the specific type of number you’re looking for, you can use this code count the digits. In case of any confusion, feel free to google it and do some research.