A C++ question
Swettacular
Utah
I'm stuck on this problem and I was hoping maybe someone here could help me: Write a program that prompts a user for a five-digit integer number and then prints the individual digits of the numbers on a line with three spaces between the digits. I'm somehow supposed to use the remainder operator(%), but I don't know how to make it work. Any help would be greatly appreciated
0
Comments
that had BETTER be right, or else i'm going to hit myself in the face. i guess i haven't touched code in 2 years though...
Input 59328
59328 % 10 = 8
59328 / 10 = 5932 (int will chop)
5932 % 10 = 2
5932 / 10 = 593
593 % 10 = 3
593 / 10 = 59
59 % 10 = 9
59 / 10 = 5
5 % 10 = 5
5 / 10 = 0 <-- done
The numbers you want are the bold ones (backwards order)
the #include is < iostream.h > ... it gets left out by the / code modifier for some reason
hooray for making things more complicated than they need be
of course youll need to add code to make sure the input is only 5 digits && numeric etc...
Sorry I didn't have an answer for you. I was AFK all day yesterday and by the time I saw this today you already had been answered.