0

Arrays Module Quiz

Hello, I do not understand int arr[ ] = new int[3]; in the first exercise of the Quiz. can you help me ? Thanks.

3/22/2018 4:06:32 PM

Meddy Monthouel

2 Answers

New Answer

+3

first of all, arrays are declared like this: int[] arr = new int[3]; arrays are tools used to sort or collect data. instead of creating 10 variables you can declare an array with 10 indexes. int means the type of the array e.g. int, double,string [] means how much dimensions will be in the array. e.g. int[][][](3 dimensions) next is the name of the array e.g. arr new is a syntax word for declaring it int represents the type of the array you declared beforehand. then [] represents how much indexes you would like to have in the array. int[] arr = new int[10] would have 10 indexes. int[][] arr = new int[9][5] would have 9 indexes in the first dimension and 5 in the second dimension. you can access array by doing that arr[3] = 5; doing that will make the index 3 of the array to be worth 5. you can print arrays by doing stuff like this. for(int x=0;x<arr.Length;x++) Console.WriteLine(arr[x]);

+1

This means: int - Type integer arr - Variable name [ ] - it's an array = - we initialize it new - that's the keyword int [3] - Integer-Array with three integers in it