While Loop | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

While Loop

Hello! I have the following code that outputs: 1 12 123 1234... depending on the number inputted. However, if you input 10 or greater, the code will output: .... 12345678910 1234567891011 123456789101112.... Is there anyway for it to output this instead: 1234567890 12345678901 123456789012... ? The code has to be two nested while loops. Thanks in advanced! https://code.sololearn.com/c42n6s0Bcd1M/?ref=app

1st Oct 2018, 1:08 PM
Miqaela Weller
Miqaela Weller - avatar
1 Answer
+ 7
Line 14: change cout << k; to cout << k%10;
1st Oct 2018, 1:14 PM
Anna
Anna - avatar