How can I create an array for twenty values by user input | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How can I create an array for twenty values by user input

Am to collect the score of twenty students using an array which should be done by the operator i. e. At the point of execution.

27th Jul 2016, 10:15 AM
Markanthony
Markanthony - avatar
5 Answers
+ 3
Hi Markanthony I published rigth now in code playground a program called "Input data in an array with ReadLine". The array has 3 positions, but you can increase more. For each input you must press enter. The program store values and then display them. I hope it helps!
27th Jul 2016, 3:30 PM
Ricardo Pucca
Ricardo Pucca - avatar
+ 1
Use a list object and a for loop to ask for user input x number of times. Each time the loop executes read the user input and add to the list. Then create another loop to write each value to the console. If you want to get slightly more advanced look into writing item values to a text file.
31st Jul 2016, 11:01 AM
Mike
Mike - avatar
0
public static void Main(String[] args) { int[] inputValues = new int[20]; for(int i=o;i<20;i++)//for array input { inputValues[i]=Convert.ToInt32(Console.ReadLine()); } for(int j=0;j<20;j++)// for print the array { Console.WriteLine(inputValues[j]); } }
1st Aug 2016, 11:56 AM
Evan Sihab
Evan Sihab - avatar
0
Evan, your correct. please format your code correctly, it would help the person asking the question
11th Nov 2016, 12:15 AM
Stuart
Stuart - avatar
0
int[] arr = new int[20];
27th Jan 2017, 4:20 PM
Idan Moral
Idan Moral - avatar