One-dimensional arrays MCQsBy: Prof. Dr. Fazal Rehman | Last updated: May 14, 2025 20 Score: 0 Attempted: 0/20 Subscribe 1. : What is the correct way to declare a one-dimensional array of integers in C? (A) int array[10]; (B) int array; (C) array int[10]; (D) int[10] array; 2. : Which of the following correctly initializes an array of size 5 with all zeros in C++? (A) int array[5] = {0}; (B) int array = {0, 0, 0, 0, 0}; (C) int array[5] = {0, 0, 0, 0, 0}; (D) int array[5] = {0, 0, 0, 0}; 3. : What is the index of the last element in an array of size n? (A) n (B) n-1 (C) n+1 (D) 0 4. : What is the time complexity of accessing an element in a one-dimensional array by its index? (A) O(n) (B) O(log n) (C) O(1) (D) O(n^2) 5. : What is the value of the first element in an array initialized as int array[3] = {1, 2, 3};? (A) 0 (B) 1 (C) 2 (D) 3 6. : How do you pass a one-dimensional array to a function in C? (A) void function(int array[10]); (B) void function(int array[]); (C) void function(int *array); (D) All of the above 7. : What is the output of the following code? int array[5] = {1, 2, 3, 4, 5}; printf(“%d”, array[2]); (A) 1 (B) 2 (C) 3 (D) 4 8. : Which of the following statements about one-dimensional arrays is false? (A) Arrays can store multiple values of the same type. (B) Array elements are stored in contiguous memory locations. (C) The size of an array must be a constant expression in C. (D) The size of an array can be changed after declaration. 9. : How can you find the number of elements in an array int array[10]; in C? (A) sizeof(array) / sizeof(array[0]) (B) sizeof(array) / sizeof(int) (C) sizeof(array[0]) / sizeof(array) (D) sizeof(int) / sizeof(array) 10. : What is the initial value of an uninitialized array in C? (A) 0 (B) Random garbage values (C) -1 (D) Null 11. : Which of the following correctly accesses the third element of an array named data? (A) data[3] (B) data[2] (C) data[1] (D) data[0] 12. : Which operation is not typically performed directly on one-dimensional arrays? (A) Insertion (B) Deletion (C) Traversal (D) Random Access 13. : In which of the following scenarios is a one-dimensional array preferred over other data structures? (A) When you need dynamic resizing (B) When you need fast random access to elements (C) When you need to store key-value pairs (D) When you need a Last-In-First-Out (LIFO) data structure 14. : What is the result of the following code? int array[4] = {1, 2}; printf(“%d”, array[3]); (A) 0 (B) 1 (C) 2 (D) Undefined behavior 15. : How do you correctly assign the value 10 to the first element of an array arr in Java? (A) arr = 10; (B) arr[0] = 10; (C) arr[1] = 10; (D) arr[] = 10; 16. : Which of the following statements about arrays in Java is true? (A) Arrays can have elements of different types. (B) The length of an array can be changed after it is created. (C) The size of an array must be specified when it is created. (D) Arrays are passed by value to methods. 17. : What is the output of the following code in Python? arr = [1, 2, 3, 4, 5]; print(arr[-1]) (A) 1 (B) 2 (C) 4 (D) 5 18. : Which function would you use to find the length of an array arr in Python? (A) size(arr) (B) len(arr) (C) length(arr) (D) count(arr) 19. : How do you declare an array of 10 integers in JavaScript? (A) var array = new Array(10); (B) var array = [10]; (C) int array[10]; (D) array = (10); 20. : What is the output of the following code? int array[5] = {1, 2, 3, 4, 5}; printf(“%d”, array[5]); (A) 1 (B) 5 (C) 0 (D) Undefined behavior Data Structures MCQs Basic Concepts Introduction to Data Structures Abstract Data Types (ADT) MCQs Complexity Analysis MCQs Time complexity MCQs Space complexity MCQs Big O, Big Ω, Big Θ notations MCQs Linear Data Structures MCQs Arrays MCQs One-dimensional arrays MCQs Multi-dimensional arrays MCQs Operations: traversal, insertion, deletion MCQs Linked Lists MCQs Singly linked list MCQs Doubly linked list MCQs Circular linked list MCQs Stacks MCQs Stack operations (push, pop, peek) MCQs Applications of stacks (expression evaluation, recursion) MCQs Queues MCQs Queue operations (enqueue, dequeue, front, rear) MCQs Types: Simple queue, circular queue, priority queue, deque MCQs Non-Linear Data Structures MCQs Trees MCQs Binary trees MCQs Binary Search Trees (BST) MCQs AVL Trees MCQs B-trees and B+ trees MCQs Tree traversal methods (in-order, pre-order, post-order) MCQs Heaps MCQs Min-heap MCQs Max-heap MCQs Heap operations (insertion, deletion, heapify) MCQs Applications of heaps (priority queues, heap sort) MCQs Graphs MCQs Graph representation (adjacency matrix, adjacency list) MCQs Graph traversal algorithms (DFS, BFS) MCQs Shortest path algorithms (Dijkstra’s, Bellman-Ford) MCQs Minimum Spanning Tree (Kruskal’s, Prim’s) MCQs Hashing MCQs MCQs Hash Tables Hash functions MCQs Collision resolution techniques (chaining, open addressing) MCQs Applications of hashing MCQs Sorting and Searching Algorithms MCQs Sorting Algorithms MCQs Bubble sort MCQs Selection sort MCQs Insertion sort MCQs Merge sort MCQs Quick sort MCQs Heap sort MCQs Searching Algorithms MCQs Linear search MCQs Binary search MCQs Interpolation search MCQs Miscellaneous Memory Management in data structures MCQs Dynamic memory allocation MCQs Garbage collection MCQs String Manipulation Algorithms MCQs Pattern matching (KMP, Rabin-Karp) MCQs String hashing MCQs Data Structures MCQs 1 Data Structures MCQs 2 Data Structures MCQs 3 Data Structures MCQs 4 Data Structures MCQs 5 Stacks Solved MCQs Queues MCQs pointer mcqs Array MCQs Related Posts:2 Dimensional Arrays in C / C++ with Sum of ArraysArrays MCQs Questions Answers - C++Arrays MCQsMulti-dimensional arrays MCQsField Programmable Gate Arrays (FPGAs) MCQsArrays in C++