Is it possible to accept array elements from the user? If so, how should I proceed? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is it possible to accept array elements from the user? If so, how should I proceed?

22nd Jul 2015, 5:08 PM
Chaitri
1 Answer
+ 1
It sure is! You are hot on to something good! Try using a "for" loop set to run the same number of times as there are values or places in the array. Take in the new value at the end of each loop before it decides to repeat or not. For fun you could try also creating another variable for the size of the array (the value inside the brackets []), and get that value from the user as well, and only then declare the array, using the value input by the user. This way the user first chooses the size of the array & then inputs each value. That way they can't blame you for making them work too hard :-)
28th Jul 2015, 10:08 PM
html ninja