Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare an array of integers.
C Sharp (C#)
int[] numbers = new int[[1]]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name instead of a number for the size.
Using the type name instead of a number.
✗ Incorrect
The number inside the brackets specifies the size of the array, which is 5 here.
2fill in blank
mediumComplete the code to access the first element of the array.
C Sharp (C#)
int firstNumber = numbers[1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses instead of square brackets.
Using curly braces or angle brackets.
✗ Incorrect
Arrays in C# use square brackets to access elements by index, starting at 0.
3fill in blank
hardFix the error in the code to assign a value to the second element of the array.
C Sharp (C#)
numbers[1] = 10;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses or other brackets instead of square brackets.
✗ Incorrect
To assign a value to an array element, use square brackets with the index.
4fill in blank
hardFill both blanks to create an array of strings with 3 elements.
C Sharp (C#)
string[] fruits = new string[[1]] {"apple", "banana", [2];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatch between array size and number of elements.
Missing quotes around string elements.
✗ Incorrect
The array size is 3, and the third element is "orange".
5fill in blank
hardFill all three blanks to create an array of doubles and assign values.
C Sharp (C#)
double[] temperatures = new double[[1]] { [2], [3], 23.5 };
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using integer values without decimal points.
Mismatch between size and number of elements.
✗ Incorrect
The array size is 3, and the first two values are 20.0 and 18.7.