+ 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
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
+ 2
with while loop
https://code.sololearn.com/cWyH289vY89v/?ref=app
+ 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)
+ 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;
}
+ 1
Thanks. But what can I do if want to use the while loop to get the result I want ?