+ 2

Hello new here... How can I take the users input, put it in an array, then show the array?

i use cin to take input, and cout to show the array. My problem is how do I put the input inside the array? thanks

13th May 2018, 8:48 AM
Christian Ibaoc
4 Answers
+ 4
int tab[10]; int var=0; for ( int i = 0; i < 10; ++i) { cin >> var; tab[i] = var; }
13th May 2018, 9:01 AM
Jakub Stasiak
Jakub Stasiak - avatar
+ 2
int tab[10]; then you do for loop with for example: "i" as iteration variable, and inside you write: cin >> variable; tab[i] = variable;
13th May 2018, 8:54 AM
Jakub Stasiak
Jakub Stasiak - avatar
+ 2
can you please give a more detailed example please? thanks
13th May 2018, 8:59 AM
Christian Ibaoc
+ 2
Woah alright it worked thanks alot man
13th May 2018, 9:32 AM
Christian Ibaoc