CPP Array MCQ
Cpp MCQ(1) Which of the following parenthesis are used while initialization of array ?
A) [ ]
B) { }
C) ( )
D) None
Explanation
Curly parenthesis are used while initialization of array. In curly parenthesis array elements are separated by comma's.
(2) Which of the following is last index of array int arr[5]?
A) 5
B) 4
C) 3
D) 2
Explanation
The last index of array is always equal to size -1. Because array index starts from 0 in C++.
(3) Which of the following is valid for declaration of float type array of 10 elements?
A) float arr[10];
B) float arr(10);
C) float arr"10";
D) float arr<10>;
Explanation
Square brackets [ ] are used to define the size of array while array declaration.
(4) int arr[10] will take how many bytes in memory?
A) 20
B) 50
C) 10
D) 100
Explanation
int data type occupy different no of bytes depending on compiler used. Normally it takes two bytes in memory, so that int arr[10] will occupy 20 bytes in memory.
(5) In two dimensional array first index represent which of the following?
A) Rows
B) Columns
C) Position
D) Address
Explanation
In two dimensional array first index represent no of rows and second index represent no of columns.
(6) An array is set of memory locations.
A) Heterogenous
B) Homogeneous
C) Autonomous
D) None
Explanation
Homogeneous means of same type. Array also used to store similar type of data in memory.
(7) Which of the following parenthesis used to write index and size of array?
A) ()
B) []
C) <>
D) {}
Explanation
Square parenthesis are used while specifying size of array. These parenthesis are also used while accessing array elements with index.
(8) How many type of array are used in C++
A) 1
B) 2
C) 3
D) 4
Explanation
There are two types of arrays used in C++. Which are single and multi dimensional arrays.
(9) Array index starts with
A) 0
B) 1
C) 2
D) 4
Explanation
Array index always starts from 0 in C++.