Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare an integer array of size 5.
DSA C++
int arr[1];Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses instead of square brackets.
Using curly braces for declaration size.
Using angle brackets which are for templates.
✗ Incorrect
In C++, arrays are declared with square brackets specifying their size, like int arr[5];
2fill in blank
mediumComplete the code to initialize the array with values 1, 2, 3, 4, 5.
DSA C++
int arr[5] = [1];
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses instead of curly braces.
Using square brackets which are for indexing.
Using angle brackets which are for templates.
✗ Incorrect
Arrays in C++ are initialized using curly braces with comma-separated values.
3fill in blank
hardFix the error in the array declaration to make it valid.
DSA C++
int arr[1] = {10, 20, 30};
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses or curly braces for size.
Omitting the size when initializing with values.
✗ Incorrect
Array size must be specified in square brackets, like int arr[3];
4fill in blank
hardFill both blanks to declare and initialize a float array of size 4 with values 1.1, 2.2, 3.3, 4.4.
DSA C++
float arr[1] = [2];
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses for size or initialization.
Omitting the 'f' suffix for float literals.
✗ Incorrect
Array size uses square brackets and initialization uses curly braces with float literals suffixed by f.
5fill in blank
hardFill both blanks to declare a char array of size 6 and initialize it with characters 'a', 'b', 'c', 'd', 'e', 'f'.
DSA C++
char arr[1] = [2];
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses for size or initialization.
Using double quotes instead of single quotes for characters.
✗ Incorrect
Array size is declared with square brackets and initialization uses curly braces with single-quoted characters.
