Programming for Problem Solving - Unit-2
AA data structure that can hold multiple data types.
BA collection of elements with the same data type.
CA mathematical function.
DA loop construct.
Correct AnswerA collection of elements with the same data type.
Aint[] myArray;
Barray<int> myArray;
Cint myArray[];
Darray myArray;
Correct Answerint myArray[];
AmyArray[2]
BmyArray[3]
CmyArray[1]
DmyArray(3)
Correct AnswermyArray[2]
Aarray[2][3]
Barray[1][2]
Carray(2,3)
Darray[3][2]
Correct Answerarray[1][2]
A10
B20
C30
DNone of the above
Correct Answer20
Correct Answer4
Correct Answer20
Asizeof(arr) / sizeof(arr[0])
Bsizeof(arr)
Carr.size()
DNone of the above
Correct Answersizeof(arr) / sizeof(arr[0])
AIt returns a default value
BIt causes a segmentation fault
CIt wraps around to the start of the array
DNone of the above
Correct AnswerIt causes a segmentation fault
AAn array that can store only two elements.
BAn array of arrays, organized in rows and columns.
CAn array with two data types.
DA data structure to hold strings.
Correct AnswerAn array of arrays, organized in rows and columns.
AIt can store any data-type
BIt only stores element of similar data type to first element
CIt acquires the data type with the highest precision in it
DYou cannot have an array of void data type
Correct AnswerYou cannot have an array of void data type
Fill in the Blanks
12An array is a collection of items stored at __________ in memory.
Correct Answercontiguous locations
13In C, the index of the first element in an array is __________.
Correct Answer0
14The syntax to access the fifth element of an array named arr is __________.
Correct Answerarr[4]
15To declare a two-dimensional array in C, you use two sets of __________.
Correct Answersquare brackets
16The size of a one-dimensional array must be defined during __________.
Correct Answerdeclaration
17To find the number of elements in an array arr, the expression is __________.
Correct Answersizeof(arr) / sizeof(arr[0])
18In C, if you attempt to access an index that is out of bounds, it can lead to __________.
Correct Answerundefined behavior
19The process of iterating through an array to access or modify each element is called __________.
Correct Answerlooping (or iteration)
20To access the first element of a two-dimensional array arr, you use the syntax __________.
Correct Answerarr[0][0]