0
0
C Sharp (C#)programming~10 mins

Jagged arrays in C Sharp (C#) - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a jagged array of integers with 3 rows.

C Sharp (C#)
int[][] jaggedArray = new int[[1]][];
Drag options to blanks, or click blank then click option'
A2
B5
C3
D4
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong size for the first dimension.
Confusing jagged arrays with multidimensional arrays.
2fill in blank
medium

Complete the code to initialize the second row of the jagged array with 4 elements.

C Sharp (C#)
jaggedArray[[1]] = new int[4];
Drag options to blanks, or click blank then click option'
A3
B1
C2
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 2 instead of 1 for the second row index.
Confusing the number of elements with the index.
3fill in blank
hard

Fix the error in the code to assign the value 10 to the first element of the third row.

C Sharp (C#)
jaggedArray[[1]][0] = 10;
Drag options to blanks, or click blank then click option'
A2
B0
C3
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using 3 as an index which is out of range.
Using 1 instead of 2 for the third row.
4fill in blank
hard

Fill both blanks to create a jagged array with 2 rows, where the first row has 3 elements.

C Sharp (C#)
int[][] jaggedArray = new int[[1]][];
jaggedArray[0] = new int[[2]];
Drag options to blanks, or click blank then click option'
A2
B3
C5
D4
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the number of rows and the size of the row.
Using incorrect sizes for the array dimensions.
5fill in blank
hard

Fill all three blanks to initialize a jagged array with 3 rows, where the first row has 2 elements, the second row has 4 elements.

C Sharp (C#)
int[][] jaggedArray = new int[[1]][];
jaggedArray[0] = new int[[2]];
jaggedArray[1] = new int[[3]];
Drag options to blanks, or click blank then click option'
A3
B2
C4
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing the sizes of the rows.
Using wrong indices or sizes.