For example, if I have the number 142, how do I know it contains the digit 1, 4, and 2?
So far, I've worked out that
142/100 = 1
142 -(1*100) = 42
42/10 = 4
42 - (4*10) = 2
So i can just use a looping system. But is there a simpler solution to find the digits than the method shown above?
yeah try getting the remainder
142 % 10 = 2
142 / 10 = 14 (integer division)
14 % 10 = 4
14 / 10 = 1 (integer division)
1 % 10 = 1
1 / 10 = 0 (integer division) stops when the result or the number is 0