JOHNSMITH8338 JOHNSMITH8338 - 1 year ago 88
C++ Question

How to find the second to last digit of a six digit number?

For example, if the number is 431678 I need to find the 7 and 8.

To find the 8 I divide the number (with %) by 10. I don't know how to find the 7. I assume I use division possibly by 10000? How can I get my program to print 7(second to last digit)? It's obviously a simple program so I'm looking for the simple arithmetic.

Answer Source
const unsigned x = 431678;
std::cout << ((x / 10) % 10);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download