+ 1

Hi. What is wrong with this code

I am trying to get a 100 inputs from the user and print it out. What this code actually does is only use the first input and prints it out 100 times , which o don’t want . Thanks in advance

7th May 2018, 9:08 AM
Dyary
Dyary - avatar
8 Answers
+ 3
or alternatively to Donna if you compile your program on your pc and want to print all the numbers at once after you entered the numbers you should yse a second loop for cout. just repkçlace 5 with 100. https://code.sololearn.com/csgvt3sgR69R/?ref=app
7th May 2018, 9:23 AM
storm
storm - avatar
7th May 2018, 9:30 AM
storm
storm - avatar
+ 1
Which code you mean? There is no link or code. But I guess it is a flaw of Sololearns input boxes. There is only one before running the code, which is quite inconvenient when you want to request input in the middle of the code/game (like programming an RPG, as suggested in the end of Python tutorial)
7th May 2018, 9:19 AM
Matthias
Matthias - avatar
+ 1
Sorry about that, here is the code #include <iostream> using namespace std; int main() { int a = 0; string b; while (a < 100){ cin >> b; cout << b << endl; a++; } return 0; }
7th May 2018, 9:22 AM
Dyary
Dyary - avatar
+ 1
Thanks. But what can I do if want to use the while loop to get the result I want ?
7th May 2018, 9:25 AM
Dyary
Dyary - avatar