-
C++ problem
How can I write a program that when I input a five-digit number, it'll help me to separates the number into its individual digits and prints the digits separated from one another by three spaces each by using the integer division and modulus operators? thx!~
-
Well, as I bet this is a homework problem, here are hints, not answers:
x % 10 is the remainder of x divided by 10, and
x / 10 is the integer part of x divided by 10.
These are related to the decimal digits of x. If you don't see how, break out a pencil and paper, and try doing long division (I hope you paid attention in 4th grade!) on the following numbers:
76540
45082
66538
Now, your quotient will be x/10, and your remainder is x%10. Once you've calculated the quotients and remainders it should be obvious how you should implement the program.