First logic is the easiest and is the common to think. It uses loop to count number of digits. To count number of digits divide the given number by 10 till number is greater than 0. For each iteration increment the value of some count variable.
For More Information Please Refer: