CPA-21-02 practice question 3 of 35
Which of the following statements are correct about an array? int tab[10];
Full set: 257 questionsIn C++, the declaration int tab[10]; allocates a contiguous block of memory for an array capable of storing exactly 10 integer elements. C++ arrays utilize zero-based indexing, meaning the index of the first element is 0 and the index of the last element is N-1 (where N is the size of the array). Therefore, tab[0] accesses the first element, and tab[9] correctly designates the tenth and final element in the array.
B: Incorrect because C++ arrays are zero-indexed; the expression tab[1] designates the second element in the array, not the first. D: Incorrect because C++ does not mandate array initialization at the time of declaration; uninitialized local arrays simply contain indeterminate (garbage) values.
1. ISO/IEC 14882:2017 (C++17 Standard), Section 11.3.4 [dcl.array], Paragraph 1-3 (Array declarations and bounds).
2. Stanford University CS106L Standard C++ Programming, Array and Pointer semantics.
Keep practicing
Take the free CPA-21-02 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other CPA-21-02 practice questions
- Question 1What happens when you attempt to compile and run the following code? #include using names…
- Question 2What happens when you attempt to compile and run the following code? #include #include us…
- Question 4What happens when you attempt to compile and run the following code? #include #include us…
- Question 5What is the output of the program if characters 'h', 'e', 'l', 'l' , 'o' and enter are su…
- Question 6What happens when you attempt to compile and run the following code? #include using names…
- Question 7What happens when you attempt to compile and run the following code? #include using names…
