| xCV5211x (3) | |||
|
Hello all, I'm beginning to learn C++, and I need to write a program that prints n rows of digits. The nth row needs to read 1234...n. Also, if a row has more than 10 digits, the digit after 9 should start from 0. For example: If n = 12, output should be: 1 12 123 1234 12345 123456 1234567 12345678 123456789 1234567890 12345678901 123456789012 My code so far is:
My code outputs: 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 (ect...) For numbers greater than 10, I need to use x%10 to compute x mod 10. I'm not sure how to get the output horizontal rather than vertical. I also don't have a great grasp of loops within loops, which probably contributes to my problem. Can anyone help me out? Thanks | |||
|
Last edited on
|
|||
| eraggo (146) | |
|
First: use code tags, please. Second: Hint, Try to remove one endl. Third: Another hint, use x mod 10 always | |
|
|
|
| xCV5211x (3) | |
| eraggo, thanks for the help. I got it now | |
|
|
|