I would like to split a two digit int into 2 one digit ints! For example:
20 = 2 and 0
15 = 1 and 5
8 = 0 and 8
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That’s easy: use
%to get the mod of the number, and/for the integer division (i.e. division where the fractional part is discarded).Your numbers are in the decimal system (i.e. the base is
10) so you divide and mod by 10, like this:To print a number digit-by-digit, least significant digit first, you can use this loop: