We can use math operations to count the number of digits in an integer. One way to do this is to repeatedly divide the integer by 10, counting the number of times until it becomes 0. Here's the code:
main.cs162 chars11 lines
Alternatively, we can convert the integer to a string and count the number of characters:
main.cs133 chars5 lines
Both of these methods will give the same result.
gistlibby LogSnag