Complete the code to declare an array of 5 integers in C++.
int numbers[[1]];The number inside the brackets specifies the size of the array. Here, 5 means the array can hold 5 integers.
Complete the code to access the third element of the array named 'data'.
int value = data[[1]];Array indexing in C++ starts at 0, so the third element is at index 2.
Fix the error in the code to correctly initialize an array with values 1, 2, 3.
int arr[3] = { [1] };
Array initialization requires comma-separated values inside braces.
Fill both blanks to create an array of size 4 and assign 10 to its first element.
int arr[[1]]; arr[[2]] = 10;
The array size is 4, and the first element index is 0.
Fill all three blanks to declare an array, assign a value, and print the second element.
#include <iostream> int main() { int arr[[1]] = {5, 10, 15}; arr[[2]] = 20; std::cout << arr[[3]] << std::endl; return 0; }
The array size is 3, the second element index is 1, and printing the third element uses index 2.
