How to extract all the digits from a number without using modulus and String ? e.g. 1234 should return 1, 2, 3 and 4 separately.
I don't understand why you don't want to use modulo, but here you go:
I assume 1234 is of type int
. You can divide this number by 10, giving you 123. Afterwards, you subtract the original number by 10*123, i.e. 1234 - 10*123. This gives you the last digit, 4. Afterwards, you do the same on 123 and so on, until the number divided by 10 is 0. In the end, it will just simulate a modulo operator.