Explore topic-wise MCQs in Arrays .

This section includes 100 Mcqs, each offering curated multiple-choice questions to sharpen your Arrays knowledge and support exam preparation. Choose a topic below to get started.

51.

Array base address in C language

A. Base address is the address of 0th index element.
B. An array b[] base address is &b[0]
C. An array b[] base address can be printed with printf("%d", b);
D. None of the above
Answer» B. An array b[] base address is &b[0]
52.

Comment on the below statements with respect to A and B int *a1[8]; int *(a2[8]); A. Array of pointers B. Pointer to an array

A. a1 is A, a2 is B
B. a1 is B, a2 is A
C. a1 is A, a2 is A
D. a1 is B, a2 is B
Answer» D. a1 is B, a2 is B
53.

The maximum number of dimension an array can have in C is

A. compiler dependent
B. Only 2
C. Only 3
D. Only 4
Answer» B. Only 2
54.

Syntax of accessing the seventh element

A. a{7}
B. a(7)
C. a"7"
D. a[7]
Answer» E.
55.

What are the Types of Arrays?

A. int, float, char, double
B. struct, enum
C. long
D. All the above
Answer» E.
56.

Predict the output of below code: #include "stdio.h" #include "stdlib.h" int main(int argc, char *argv[]) { char temp[20]; gcvt(23.45,2, temp); printf("%s", temp); return 0; }

A. Output : 0.4
B. Output : 24.4
C. Output : 25.4
D. Output : 23
Answer» E.
57.

Let x be an array. Which of the following are illegal

A. x++
B. x+1
C. x*2
D. none of these
Answer» B. x+1
58.

Size of the array need not be specified, when

A. It is a declaratrion
B. Initialization is a part of definition
C. It is a formal parameter
D. All the above
Answer» C. It is a formal parameter
59.

Predict the output of below code: #include stdio.h int main() { struct site { char name[] = "GeeksforGeeks"; int no_of_pages = 200; }; struct site *ptr; printf("%d",ptr->no_of_pages); printf("%s",ptr->name); getchar(); return 0; }

A. GeeksforGeeks
B. Compilation Error
C. Runtime Error
D. Geeks
Answer» C. Runtime Error
60.

If a two dimensional array is used as a formal parameter, then

A. the first subscript must be left empty
B. the first (row) subscript may be left empty
C. both the subscripts must be left empty
D. both the subscripts may be left empty
Answer» C. both the subscripts must be left empty
61.

What is the value of a[4]? int a[5]={1,2,4,1,0}

A. 1 .
B. 10 .
C. 0 .
D. Error
Answer» D. Error
62.

What is the output of C program with arrays? int main() { int a[3] = {20,30,40}; int b[3]; b=a; printf("%d", b[0]); }

A. Compiler Error
B. Output : 20
C. Output : 30
D. Output : 0
Answer» B. Output : 20
63.

What will be the output of the program ? #include int main() { int a[5] = {5, 1, 15, 20, 25}; int i, j, m; i = ++a[1]; j = a[1]++; m = a[i++]; printf("%d, %d, %d", i, j, m); return 0; }

A. 2, 1, 15
B. 1, 2, 5
C. 3, 2, 15
D. 2, 3, 20
Answer» D. 2, 3, 20
64.

What will be the output of the program ? #include void fun(int **p); int main() { int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 8, 7, 8, 9, 0}; int *ptr; ptr = &a[0][0]; fun(&ptr); return 0; } void fun(int **p) { printf("%d n", **p); }

A. 1
B. 2
C. 3
D. 4
Answer» B. 2
65.

What does the following declaration mean? int (*ptr)[10];

A. ptr is array of pointers to 10 integers
B. ptr is a pointer to an array of 10 integers
C. ptr is an array of 10 integers
D. ptr is an pointer to array
Answer» C. ptr is an array of 10 integers
66.

Which of the following statements mentioning the name of the array begins DOES NOT yield the base address? 1. When array name is used with the sizeof operator. 2. When array name is operand of the & operator. 3. When array name is passed to scanf() function. 4. When array name is passed to printf() function.

A. A
B. A, B
C. B
D. B, D
Answer» C. B
67.

What will be the output of the program if the array begins 1200 in memory? #include int main() { int arr[]={2, 3, 4, 1, 6}; printf("%u, %u, %u n", arr, &arr[0], &arr); return 0; }

A. 1200, 1202, 1204
B. 1200, 1200, 1200
C. 1200, 1204, 1208
D. 1200, 1202, 1200
Answer» C. 1200, 1204, 1208
68.

What will be the output of the program ? #include int main() { float arr[] = {12.4, 2.3, 4.5, 6.7}; printf("%d n", sizeof(arr)/sizeof(arr[0])); return 0; }

A. 5
B. 4
C. 6
D. 7
Answer» C. 6
69.

Is there any difference int the following declarations? int fun(int arr[]); int fun(int arr[2]);

A. Yes
B. No
Answer» C.
70.

Consider an array consisting of ve and +ve numbers. What would be the worst case time complexity of an algorithm to segregate the numbers having same sign altogether i.e all +ve on one side and then all -ve on the other ?

A. O(N)
B. O(N Log N)
C. O(N * N)
D. O(N Log Log N)
Answer» B. O(N Log N)
71.

What is meaning of the following statement ? int *ptr[20]

A. None of these
B. Integer Array to Integer Pointers having size 20
C. Array of Integer Pointers of size 20
D. Integer Array of size 20 pointing to an Integer Pointer
Answer» D. Integer Array of size 20 pointing to an Integer Pointer
72.

What is meaning of following declaration ? int arr[20];

A. Integer Array of size 20
B. None of these
C. Array of size 20 that can have integer address
D. Array of Size 20
Answer» B. None of these
73.

What will be the size of above array element ? int a[20]

A. 22
B. 21
C. 20
D. 19
Answer» D. 19
74.

Predict the output of below code: int main() { char a[2][3][3] = {'g','e','e','k','s','f','o', 'r','g','e','e','k','s'}; printf("%s ", **a); getchar(); return 0; }

A. Geeks
B. Error
C. geeksforgeeks
D. No Output
Answer» D. No Output
75.

If storage class is missing in the array definition, by default it will be taken to be

A. either automatic or external depending on the place of occurrence
B. automatic
C. static
D. external
Answer» B. automatic
76.

Predict the output of below code: #include int main() { int arr[1]={10}; printf("%d n", 0[arr]); return 0; }

A. Output : 1
B. Output : 10
C. Output : 6
D. Output : 8
Answer» C. Output : 6
77.

Pick out the output #include int main() { foo(ary); } void foo(int **ary) { int i = 10, k = 10, j = 2; int *ary[2]; ary[0] = &i; ary[1] = &j; printf("%d n", ary[0][1]); }

A. compile time error
B. Runtime error
C. Output : 20
D. Undefined Behaviour
Answer» E.
78.

Point the correct statement

A. An array element may be an array by itself
B. Strictly speaking C supports 1-dimensional arrays only
C. Both A and C
D. Array elements need not occupy contiguous memory locations
Answer» D. Array elements need not occupy contiguous memory locations
79.

The minimum number of comparisons required to determine if an integer appears more than n/2 times in a sorted array of n integers is

A. (n)
B. (logn)
C. (log*n)
D. (1)
Answer» C. (log*n)
80.

A program P reads in 500 integers in the range [0..100] exepresenting the scores of 500 students. It then prints the frequency of each score above 50. What would be the best way for P to store the frequencies?

A. An array of 50 numbers
B. An array of 100 numbers
C. An array of 500 numbers
D. A dynamically allocated array of 550 numbers
Answer» B. An array of 100 numbers
81.

What will be the address of the arr[2][3] if arr is a 2-D long array of 4 rows and 5 columns and starting address of the array is 2000?

A. 2048
B. 2056
C. 2052
D. 2042
Answer» D. 2042
82.

A one dimensional array A has indices 1....75. Each element is a string and takes up three memory words. The array is stored at location 1120 decimal. The starting address of A[49] is

A. 1264
B. 1164
C. 1167
D. 1267
Answer» B. 1164
83.

Consider a two dimensional array A[20][10]. Assume 4 words per memory cell, the base address of array A is 100, elements are stored in row-major order and first element is A[0][0]. What is the address of A[11][5] ?

A. 560
B. 460
C. 570
D. 575
Answer» B. 460
84.

What is the maximun number of dimensions an array in C may have?

A. Two
B. eight
C. sixteen
D. Theoratically no limit. The only practical limits are memory size and compilers
Answer» E.
85.

Consider the following type definition. typedef char x[10]; x myArray[5]; What will sizeof(myArray) be ? (Assume one character occupies 1 byte)

A. 15 bytes
B. 10 bytes
C. 50 bytes
D. 30 bytes
Answer» D. 30 bytes
86.

If storage class is missing in the array definition, by default it will be taken to be

A. automatic
B. external
C. static
D. either automatic or external depending on the place of occurrence
Answer» E.
87.

Consider the array definition int num [10] = {3, 3, 3}; Pick the Correct answers

A. num [9] is the last element of the array num
B. The value of num [ 8] is 3
C. The value of num [ 3 ] is 3
D. None of the above
Answer» B. The value of num [ 8] is 3
88.

In general, the index of the first element in an array is __________

A. -1
B. 2
C. 1
Answer» A. -1
89.

The const feature can be applied to

A. an identifier
B. an array
C. an array argument
D. All of these
Answer» E.
90.

Assuming int is of 4bytes, what is the size of int arr[15];?

A. 15
B. 19
C. C.
D. D.
Answer» E.
91.

What are the disadvantages of arrays?

A. Data structure like queue or stack cannot be implemented
B. There are chances of wastage of memory space if elements inserted in an array are lesser than the allocated size
C. Index value of an array can be negative
D. Elements are sequentially accessed
Answer» C. Index value of an array can be negative
92.

The minmum number of inter changes needed to convert the array 89,19,40,17,12,10,2,5,7,11,6,9,70 into a heap with maximum element at the root is

A. 1
B. 2
C. 4
D. None of these
Answer» C. 4
93.

In which of the following cases, linked list implementation of sparse matrices consumes the same memory space as the conventional way of storing the entire array?

A. 5x6 matrix with 9 non-zero entries
B. 5x6 matrix with 10 non-zero entries
C. Efficient in accesing an entry
D. Efficient if the sparse matrix is a band matrix
Answer» D. Efficient if the sparse matrix is a band matrix
94.

The information about an array used in a program will be sorted in

A. Symbol table
B. Activation record
C. Both (a) and (b)
D. Dope vector
Answer» E.
95.

Which of the following is an illegal array definition?

A. Type COLOGNE:(LIME,PINE,MUSK,MENTHOL); var a:array[COLOGNE]of REAL;
B. var a:array[REAL]of REAL;
C. var a:array['A'..'Z']of REAL;
D. var a:array[BOOLEAN]of REAL;
Answer» C. var a:array['A'..'Z']of REAL;
96.

Minimun number of comparison required to compute the largest and second largest element in array is

A. n-[log n]-2
B. n+[log n-2]
C. log n
D. None of these
Answer» C. log n
97.

What are the advantages of arrays?

A. Objects of mixed data types can be stored
B. Elements in an array cannot be sorted
C. Index of first element of an array is 1
D. Easier to store elements of same data type
Answer» E.
98.

Which of these best describes an array?

A. A data structure that shows a hierarchical behaviour
B. Container of objects of similar types
C. Arrays are immutable once initialised
D. Array is not a data structure
Answer» C. Arrays are immutable once initialised
99.

How do you initialize an array in C?

A. int arr[3] = (1,2,3);
B. int arr(3) = {1,2,3};
C. int arr[3] = {1,2,3};
D. int arr(3) = (1,2,3);
Answer» D. int arr(3) = (1,2,3);
100.

Choose the statement that best defines an array

A. It is a collection of items that share a common name
B. It is a collection of items that share a common name and occupy consecutive memory location
C. It is a collection of items of the same type and storage class that share a common name and occupy consecutive memory locations
D. None of the above
Answer» D. None of the above