One-dimensional and multi-dimensional arrays — C++ MCQs

31
Score: 0
Attempted: 0/31
1. What is a one-dimensional array in C++?



2. How do you declare an array of 5 integers in C++?



3. What is the index of the first element in a C++ array?



4. How do you access the 3rd element of an array named arr?



5. Which of the following is correct initialization of a one-dimensional array?



6. What will be the output of this code?
int arr[3] = {5, 10, 15};
cout << arr[1];




7. What is a two-dimensional array?



8. How do you declare a 2×3 integer array?



9. How do you access the element at 2nd row and 3rd column of arr?



10. What is the output?
int arr[2][2] = {{1,2},{3,4}};
cout << arr[1][0];




11. What is the default value of an uninitialized global array?



12. What is the output of this code?
int arr[5];
cout << arr[0];




13. Can arrays in C++ have variable size?



14. How is memory allocated for a 2D array?



15. How do you initialize a 2×2 array with zeros?



16. What will be the output?
int arr[3] = {1,2};
cout << arr[2];




17. Which of the following is illegal?



18. How do you declare a 3D array?



19. What is the output of this code?
int arr[2][3] = {{1,2,3},{4,5,6}};
cout << arr[1][2];




20. How do you calculate the number of elements in a 1D array arr?



21. Arrays in C++ are:



22. What is wrong with the declaration?
int arr[];




23. Which of the following is correct for multi-dimensional array initialization?



24. What is the output of this code?
int arr[3] = {5};
cout << arr[1];




25. How do you access elements in a multi-dimensional array using loops?



26. Which of the following is true about arrays in C++?



27. What will the output?
int arr[2][3] = {{1,2,3},{4,5,6}};
cout << arr[0][2];




28. Can you partially initialize a 2D array?



29. Which of the following is invalid?



30. What is the output of this code?
int arr[2][2] = {{1,2},{3,4}};
cout << sizeof(arr)/sizeof(arr[0]);




31. Which of the following is true about multi-dimensional arrays?



Contents Copyrights Reserved By T4Tutorials