4.1.1 - Introduction to Array and its Types.
1. What is the primary purpose of an array in programming?
Correct Answer: (B) Store multiple values within a single variable
2. What is the starting index for an array in C?
Correct Answer: (B) 0
3. How can an array be declared in C?
Correct Answer: (A) int array[];
4. What type of values can arrays hold?
Correct Answer: (C) Any data type
5. Which of the following is NOT an operation that can be performed on an array?
Correct Answer: (B) Inheritance
6. How do you access the first element of an array named "arr"?
Correct Answer: (B) arr[0]
7. What will be the output of the following code snippet?
int arr[3] = {1, 2, 3}; printf("%d", arr[3]);
Correct Answer: (C) Compilation error
8. In the declaration int arr[5] = {1, 2, 3}; what happens to the remaining two elements?
Correct Answer: (A) They are set to 0
9. Which of the following statements is true about arrays in C?
Correct Answer: (C) Arrays have a fixed size once declared
10. What does the process of array subscripting involve?
Correct Answer: (B) Accessing specific elements using their index
11. What is the time complexity for retrieving any array element?
Correct Answer: (C) O(1)
12. How many dimensions can an array have in C?
Correct Answer: (C) Unlimited
13. What is the syntax to declare a one-dimensional array of integers?
Correct Answer: (C) Both a and b
14. Which of the following is a disadvantage of using arrays?
Correct Answer: (C) Their size cannot be changed after initialization
15. How can an array be initialized with a loop?
Correct Answer: (B) By using a for loop
16. In the array declaration int arr[10]; how many elements can it hold?
Correct Answer: (B) 10
17. What is the output of the following code?
int arr[5] = {0, 1, 2, 3, 4}; printf("%d", arr[2]);
Correct Answer: (C) 2
18. Which operation is used to combine two different arrays?
Correct Answer: (A) Merging
19. What is the purpose of the loop in the following code?
for (i = 0; i < 5; i++) { arr[i] = i + 1; }
Correct Answer: (B) To initialize the array elements
20. What will be the output of the following code?
int arr[5] = {1, 2, 3, 4, 5}; arr[2] = 10;
printf("%d", arr[2]);
Correct Answer: (C) 10
21. How are multidimensional arrays stored in memory?
Correct Answer: (A) Row-major order
22. What is a 2-dimensional array commonly referred to as?
Correct Answer: (B) Array of arrays
23. Which of the following is a valid 2-dimensional array declaration?
Correct Answer: (C) int array[3][3] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
24. In C, how are elements in 2D arrays inserted?
Correct Answer: (A) Through loops
25. Which function is used to read elements into a 2D array?
Correct Answer: (B) scanf
26. How can an element in a 2D array be updated?
Correct Answer: (B) By modifying the required index position
27. How is the row number of an element in a 2D array removed?
Correct Answer: (B) Using loops to overwrite the elements
28. What is the result of multiplying two matrices?
Correct Answer: (C) Matrix multiplication results in a new matrix
29. How is matrix multiplication performed?
Correct Answer: (B) By multiplying each row of the first matrix with each column of the second matrix
30. How are rows and columns specified for a 2D array in C?
Correct Answer: (C) Can be omitted for rows, but columns must be specified
31. What is the syntax to declare a 2D array in C?
Correct Answer: (B) data_type array_name[rows][columns];
32. What is the dimension of an array defined as int arr[4][3]?
Correct Answer: (A) 12 elements
33. Which one of the following is a correct syntax for declaring a 2D array?
Correct Answer: (C) int arr[2][3] = {1, 2, 3, 4, 5, 6};
34. What will be the result of int arr[2][3] = {1, 2, 3, 4, 5, 6};?
Correct Answer: (C) 2 rows and 3 columns matrix
35. What is a matrix in a 2D array referred to when rows and columns are equal?
Correct Answer: (C) Square matrix
36. How does matrix multiplication handle elements of the resulting matrix?
Correct Answer: (C) By summing the products of the respective row and column elements
37. What does the second index of a 2D array represent?
Correct Answer: (A) The column number
38. When dynamically allocating a 2D array, what does malloc() return?
Correct Answer: (A) Pointer to the first element
39. What is the output of the following code:
int arr[2][2] = {{1, 2}, {3, 4}}; printf("%d", arr[1][1]);?
Correct Answer: (D) 4
40. What is the correct way to access the first row and second column of a 2D array named 'matrix'?
Correct Answer: (C) matrix[0][1]