Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare an integer array named numbers with size 5.
DSA C#
int[] numbers = new int[[1]];Attempts:
3 left
💡 Hint
Common Mistakes
Using zero as the size which creates an empty array.
Forgetting to specify the size inside the brackets.
✗ Incorrect
The array size is specified inside the brackets. Here, 5 means the array can hold 5 integers.
2fill in blank
mediumComplete the code to initialize the array with values 1, 2, 3, 4, 5.
DSA C#
int[] numbers = new int[] [1];Attempts:
3 left
💡 Hint
Common Mistakes
Using square brackets [] instead of curly braces {}.
Using parentheses () or angle brackets <> which are invalid here.
✗ Incorrect
Arrays in C# are initialized using curly braces {} with values separated by commas.
3fill in blank
hardFix the error in the array declaration to create a string array named fruits with 3 elements.
DSA C#
string[] fruits = new string[[1]];Attempts:
3 left
💡 Hint
Common Mistakes
Using a string "3" instead of the integer 3.
Using words like 'three' which are invalid.
✗ Incorrect
The size of the array must be an integer without quotes. Using 3 correctly sets the size to three elements.
4fill in blank
hardFill both blanks to declare and initialize an array of doubles named prices with values 10.5, 20.0, and 30.75.
DSA C#
double[] prices = new double[[1]] [2];
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses or square brackets for initialization.
Mismatch between size and number of values.
✗ Incorrect
The array size is 3 and the values are initialized using curly braces {}.
5fill in blank
hardFill both blanks to declare and initialize a char array named vowels with 'a', 'e', 'i', 'o', 'u'.
DSA C#
char[] vowels = new char[[1]] [2];
Attempts:
3 left
💡 Hint
Common Mistakes
Using square brackets or parentheses for initialization.
Using double quotes instead of single quotes for chars.
✗ Incorrect
The array size is 5 and the values are initialized using curly braces with single quotes for chars.
