Q:

Given a n digit long integer, how to access its parts?

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?

A:

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.

