Write a program that prompts the user for a positive integer n = didi-1...d1 and then displays in one column each of the digits in the number n. The rightmost digit, d1, should be listed at the top of the column.
Example:
Enter a positive number: 3704
The digits of 3704 are:
4
0
7
3
Hint: The value of the first digit can be computed by using
digit = n % 10;
Next, continue on the number 370, obtained by dividing 3704 to 10.
Help you want, Help you get.
First replace all occurings of _new to number. (Delete the declaration though)
In the while condition rewrite the >=0 to >0.
And your problem is solved.
What were the mistakes? I'll leave it to you to figure it out. And there is one more problem. I'll leave it to you too. Enjoy!!
Your program as posted above doesn't even compile. You need to fix that first.
I'd agree that you probably want to rename your _new variable. Beginning application symbols with an underbar is not good form, and may result in symbol collisions.
You don't need three variables for this problem; just the number input by the user, and the digit you wish to print.
Your test for number doesn't have to be ">="...it can be ">". Technically, this would result in the printing of any leading zeroes in the number, so that might be a flaw.
If so, you can correct it by having an accumulator that reconstructs the original number, and checking against that to see if you're done. You'll have to save the original number in a different variable, so you will need more than two variables for this solution.
You have excessive code in your do loop. You don't need two couts, nor do you need to calculate digit twice.
And, if you replace the ">=" with ">" it should work for all numbers without leading zeroes.
Edit: after looking at it some more, you can't solve the leading zeroes issue in the manner I suggested above. Once the input line is interpreted as an int, the leading zeroes are gone.
If your instructor wants you to account for leading zeroes, you'll have to read it in as a string, at which point the program gets a bit more complex.