Possible Duplicate:
Split an Integer into its digits c++
Given a number 4567.
In C++, how can you separately access 4, 5, 6 and 7?
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.
The ones digit is
n % 10, the tens digit is(n / 10) % 10, and so on. Be careful about negative numbers, the rules are slightly different.