Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare an integer array named numbers with 5 elements.
C++
int numbers[[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 inside the brackets.
Leaving the brackets empty.
Using zero as the size.
✗ Incorrect
The array size must be specified as an integer constant. Here, 5 elements are declared.
2fill in blank
mediumComplete the code to initialize the array numbers with values 1, 2, 3, 4, 5.
C++
int numbers[5] = [1];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using square brackets instead of curly braces.
Using parentheses instead of curly braces.
Using a string instead of a list of values.
✗ Incorrect
Arrays are initialized using curly braces with comma-separated values.
3fill in blank
hardFix the error in the array initialization to correctly initialize an array of 3 floats with values 1.1, 2.2, 3.3.
C++
float values[3] = [1];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses or square brackets instead of curly braces.
Using a string literal instead of a list of values.
✗ Incorrect
Use curly braces to initialize arrays in C++.
4fill in blank
hardFill both blanks to declare and initialize an array of 4 characters with letters 'a', 'b', 'c', 'd'.
C++
char letters[[1]] = [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.
Using double quotes instead of single quotes for characters.
✗ Incorrect
The array size must match the number of elements in the initializer list.
5fill in blank
hardFill all three blanks to declare and initialize an integer array named scores with 3 elements: 10, 20, 30.
C++
int [1][[2]] = [3];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong array name.
Mismatch between size and number of elements.
Using parentheses or square brackets for initialization.
✗ Incorrect
The array name is scores, size is 3, and initialization uses curly braces with values.