+ 2
C++ cin
What do you do when you want to find input for more than one integer at once?
4 Réponses
+ 3
The >> operator can be cascaded to read data into multiple variables. Eg:
int a, b; cin>>a>>b;
Alternatively, one can also use multiple cin statements to get the same result.
Also, on Code Playground, even for multiple cin statements present in a code fragment, only a single input dialog is displayed before the program's execution. This is because the execution does not take place on your device but rather on their server and so they require all input that will be required by the program. Thus, to input data in more than one cin statement, separate the data inside the dialog with newlines. This will redirect the input to respective cin statements. This limitation exists for all other languages in Code Playground except Web and PHP.
Also, similar queries have been posted before in the Q/A section. Kindly use the search bar next time.
https://www.sololearn.com/discuss/1544816/?ref=app
https://www.sololearn.com/Discuss/1740941/?ref=app
https://www.sololearn.com/Discuss/1741084/?ref=app
+ 2
chain extraction operators to input into several variables in one cin.
0
🧐
0
You can input as many times as you want just make sure to input everything you want under each other