create an array the size of a users input | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

create an array the size of a users input

i need to create an array the length of a users input in c# with the array starting at 1 and ending with the users input number ex: user input 5, array = {1,2,3,4,5}.

9th Sep 2018, 7:28 PM
David Aseltine
David Aseltine - avatar
3 Answers
+ 7
you could create a new array int arr[] = new int[input]; Then loop through the array length adding the value of the loop cycle to each element for(int i = 0; i < arr.length;i++){ arr[i]+=i;}
9th Sep 2018, 7:38 PM
D_Stark
D_Stark - avatar
+ 3
no probs david 👍
9th Sep 2018, 8:40 PM
D_Stark
D_Stark - avatar
+ 2
awesome think you so much
9th Sep 2018, 7:46 PM
David Aseltine
David Aseltine - avatar