0
0
C++programming~10 mins

Why arrays are needed in C++ - Test Your Understanding

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

Complete the code to declare an array of 5 integers.

C++
int numbers[[1]];
Drag options to blanks, or click blank then click option'
A0
B10
C5
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using zero or negative numbers as size.
Forgetting the size inside the brackets.
2fill in blank
medium

Complete the code to access the third element of the array named 'scores'.

C++
int thirdScore = scores[[1]];
Drag options to blanks, or click blank then click option'
A2
B1
C3
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 3 instead of 2 for the third element.
Confusing 1-based and 0-based indexing.
3fill in blank
hard

Fix the error in the code to correctly initialize an array with values 1 to 4.

C++
int arr[4] = {1, 2, 3, [1];
Drag options to blanks, or click blank then click option'
A5
B4
C0
D6
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number outside the intended sequence.
Providing fewer or more values than the array size.
4fill in blank
hard

Fill both blanks to create an array of 3 floats and assign 2.5 to the first element.

C++
float [1][[2]];
[1][0] = 2.5;
Drag options to blanks, or click blank then click option'
Aprices
B3
C4
Dvalues
Attempts:
3 left
💡 Hint
Common Mistakes
Using a size that doesn't match the intended number of elements.
Using inconsistent variable names.
5fill in blank
hard

Fill all three blanks to declare an array of 4 integers and set the last element to 10.

C++
int [1][[2]];
[1][[3]] = 10;
Drag options to blanks, or click blank then click option'
Adata
B4
C3
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using index 4 instead of 3 for the last element.
Mismatch between array size and index.