0
int numdigits(int num){

int len = 0;

while(num >= 10){
num = num/10;
len++;
}

return len;
}

This algorithm is used to count the number of digits but I can't understand it.
Someone explain it to me please :D

Thanks

3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by hfx642
Featured Replies
  • Add print statements after each line to print out the values that were set/changed on that line. Then you'll be able to understand how it works. Read More

1

Add print statements after each line to print out the values that were set/changed on that line. Then you'll be able to understand how it works.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.