Array Data Structure Quiz for Beginners Last Updated : 25 Sep, 2023 An array is a collection of items stored at contiguous memory locations. The idea is to store multiple items of the same type together. This makes it easier to calculate the position of each element by simply adding an offset to a base value, i.e., the memory location of the first element of the array (generally denoted by the name of the array).More on Array Data structure Array Quiz for beginners Array Data Structure Quiz for Beginners Please wait while the activity loads. If this activity does not load, try refreshing your browser. Also, this page requires javascript. Please visit using a browser with javascript enabled. If loading fails, click here to try again Question 1 The size of the array should always be _____ Positive Negative whole Number Real Number Array Data Structure Quiz for Beginners Discuss itQuestion 1-Explanation: Option A: The size of the array should always be positive to store some number of elements.Option B: The size of the array can never be negative, as we can never have negative number of elements to store. hence we can never have the size of array as negative.Option C: Zero is also a whole number, but we can never have zero number of elements to store. Hence, we can never have size of array as a whole number.Option D: Real number includes - positive, negative, and zero number. so we can not have this as a size of array, as mentioned above. So we can not consider the real number for size of array. Hence ( A ) is the correct option. Question 2 With the help of which operator array elements can be accessed? Parenthesis ( ) Braces { } Subscript Operator [ ] None of these Array Data Structure Quiz for Beginners Discuss itQuestion 2-Explanation: A Subscript operator is used to access the array element. Eg: if we have an array, int arr[5] = {1, 2, 3, 4, 5};To access the value, we can write: First element: arr[0],Second value: arr[1].Third Value: arr[2],Fourth Value: arr[3],Fifth Value: arr[4]. Hence Option (C) is correct. Question 3 Which of the following statement is correct about array? The size of the array is fixed. The size of the array is dynamic. Random access is not possible in an array. None of these Array Data Structure Quiz for Beginners Discuss itQuestion 3-Explanation: Arrays have a fixed size, once the memory is allocated to them, it cannot be increased or decreased, making it impossible to store extra data if required. An array of fixed size is referred to as a static array. Hence Option (A) is correct. Question 4 Which of the following syntax correctly declares an Array in C/C++? int geeks; array geeks[20]; geeks{20}; int geeks[20]; Array Data Structure Quiz for Beginners Discuss itQuestion 4-Explanation: Option A: This syntax is a popular way of declaring variables, and not Array.Option B: Array is not a keyword and hence cannot be used to declare an ArrayOption C: No data type is defined here. So array cannot be created using this syntaxOption D: This syntax is optimal for creating an array, as it contains a data type, variable name, and the array size. Hence D is the correct answer. Question 5 What is the output of the following code: C++ #include <bits/stdc++.h> using namespace std; int main() { int arr[5] = {1, 2, 3}; //Printing the value cout<< arr[4]<<endl; return 0; } 3 Compile error Run time error 0 Array Data Structure Quiz for Beginners Discuss itQuestion 5-Explanation: If the count of elements within the “{ }” is less than the size of the array, the remaining positions are considered to be ‘0’. In the above example, we can see that the array is declared like arr[5] ={1, 2, 3}; Now we can see that we have declared the size of the array as 5, and initialized only 3 elements, so by default the next two elements are assigned to Zero. Hence Option (D) is correct. Question 6 Which of the following statements correctly declares a two-dimensional integer array in C/C++? arr[5 *4] int arr[5][4]; arr[2][2] All of these Array Data Structure Quiz for Beginners Discuss itQuestion 6-Explanation: Option A is not the correct way to declare a 2-d array in C/C++, because here data type is missing and arr[5*4] means a 1-d array of size 20.Option B is the correct way to declare a 2-d array in C/C++. Here data type (int) is mentioned, the array name is mentioned, and also the number of rows and columns is mentioned at the time of declaration.Option C is not the correct way to declare a 2-d array in C/C++, because the data type is missing here. Hence Option(B) is correct. Question 7 In an array int arr[3]={1,2,3}, what will happen if we try to access arr[4] in C/C++? Run TIme error 3 0 Garbage Value Array Data Structure Quiz for Beginners Discuss itQuestion 7-Explanation: If you try to access arr[4], which is beyond the valid range of indices, it will result in undefined behavior. as providing garbage values. Hence option (D) is correct. Question 8 What is the output of the following program? C++ #include <iostream> using namespace std; int main() { int arr[5] = { 2, 6, 8, 13, 19 }; // Modifing the data for (int i = 0; i < 5; i += 2) arr[i]++; for (int i = 0; i < 5; i++) cout << arr[i] << endl; return 0; } 2, 6, 8, 13, 19 3, 6, 9, 13, 20 3, 7, 9, 14, 20 None of these Array Data Structure Quiz for Beginners Discuss itQuestion 8-Explanation: In the for Loop, we are just incrementing every even_indexed element by 1. int arr[5] = { 2, 6, 8, 13, 19 }; Eg: for (int i = 0; i < 5; i += 2) arr[i]++; It will increase the value of arr[0], arr[2], arr[4] by 1. So the output will be: {3, 6, 9, 13, 20}. Hence (B) is the correct answer. Question 9 What is the time complexity to insert a single element in the array? O(1) O(n) O(log n) none Array Data Structure Quiz for Beginners Discuss itQuestion 9-Explanation: The time Complexity to insert a single element in the array is O(1). Because we can access it from anywhere(means from start, from middle, from ending, or from anywhere) with the help of indices. Eg: int arr[5] ; Here, suppose we want to insert an element 20 at the 4th index, we can easily insert it by writing a single-line statement, and as we know a single-line statement will always take O(1) time complexity. arr[4] = 20; Likewise, at 3rd index: arr[3] =30; So on. Hence (A) is the correct option. Question 10 What is the famous mathematical example of 2-d array? cube Dice Matrix none Array Data Structure Quiz for Beginners Discuss itQuestion 10-Explanation: Matrix is the famous mathematical example of 2-d array. Hence Option(C) is correct. 123 There are 30 questions to complete. You have completed questions question Your accuracy is Correct Wrong Partial-Credit You have not finished your quiz. If you leave this page, your progress will be lost. Correct Answer You Selected Not Attempted Final Score on Quiz Attempted Questions Correct Attempted Questions Wrong Questions Not Attempted Total Questions on Quiz Question Details Results Date Score Hint Time allowed minutes seconds Time used Answer Choice(s) Selected Question Text Need more practice! Keep trying! Not bad! Good work! Perfect! Share your thoughts in the comments Add Your Comment Please Login to comment...