So I'm just getting started in C++ and need some help. I want to right a program that inputs a number as n and then outputs digits 0-9 based on n. Also each row adds one more number until the last number is the number of digits of n.

For example if n=8

output would be
1
12
123
1234
12345
123456
1234567
12345678

any help would be great!

if n is greater than 9 it starts over at 0
so 1234567890123 for 13

I'm not looking for a code to be written for me. I just would like to know what i should write. I think i need to use k++ and count with a "while" loop. But when i try to use them all i get is an output that is wrong like

1
2
3
4
5
6 and so on

and how do i change the count to 0-9? When i go above 9 its put "10" instead of "0".

the modulus operator is mod %10. i don't understand how the mod helps though.

This question has already been answered. Start a new discussion instead.