Hi, I have no idea how to separate numbers using modulus. If the user enters "12345", the program would have to output 1..2..3..4..5.
Please help :-)
Hi, I have no idea how to separate numbers using modulus. If the user enters "12345", the program would have to output 1..2..3..4..5.
Please help :-)
When you do "number modulo 10", you get the right-most( aka least significant ) digit of that number. With that in mind, you can find all of the digits with some simple division and comparison.
Devoted my life to programming...
Rather than using modulus, surely treating the number as a string/array and simply accessing each element/digit by their index, number[0], number[1], etc. would be better/easier?
Last edited by BpB; 04-24-2017 at 12:27 AM.
Yes, if the number was already available in string form them it would be easier and more sensible to do it that way. But since @Caiz mentioned modulus, I assumed they had to work with integers specifically.
Devoted my life to programming...