+ 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.
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!
+ 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.
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]);
}
}
0
Evan, your correct. please format your code correctly, it would help the person asking the question
0
int[] arr = new int[20];