Tuesday, August 16, 2011

Given a 3 digit number, find and print out each of the three digits.?

You can use a combination of integer division and modulus to get each of the 3 numbers. For example, to get C, uming x is your 3-digit number, you'd do x mod 10. To find B, you'd do (x mod 100) / 10. I'll let you figure out how to find A.

No comments:

Post a Comment