Array MCQ

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Question

We can declare an array without declare it size?


Like int n[] = { 2, 4, 12, 5, 45, 5 } ;
1. True
2. False
Question

We can declare an array without declare it size?


Like int n[] = { 2, 4, 12, 5, 45, 5 } ;
1. True
2. False

Answer: True
Question

int num[6] = { 2, 4, 12, 5, 45, 5, 7 } ; Is correct?


1. True
2. False
Question

int num[6] = { 2, 4, 12, 5, 45, 5, 7 } ; Is correct?


1. True
2. False

Answer: False
Question

A multidimensional array of dimension N is a collection of?


1. Single dimension array
2. N dimensional arrays
3. N-1 dimensional arrays
4. N-2 dimensional arrays
Question

A multidimensional array of dimension N is a collection of?


1. Single dimension array
2. N dimensional arrays
3. N-1 dimensional arrays
4. N-2 dimensional arrays

Answer: 3
Question

What is the output of the following program ?

1. 15
2. 00
3. Compiler error
4. None of the above
Question

What is the output of the following program ?

1. 1 5
2. 0 0
3. Compiler error
4. None of the above
Answer: 4
You are accessing -1 index and 4 index which is outside the limit 0 to 2.
You get only garbage values.
Question

Consider the following declaration of a ‘two-dimensional array


in C: char a[100][100]; Assuming that the main memory is
byte-addressable and that the array is stored starting from
memory address 0, the address of a[50][60]is
1. 5060
2. 5050
3. 6060
4. 6500
Question

Consider the following declaration of a ‘two-dimensional array


in C: char a[100][100]; Assuming that the main memory is
byte-addressable and that the array is stored starting from
memory address 0, the address of a[50][60]is
1. 5060
2. 5050
3. 6060
4. 6500

Answer: A
Row major ordering
Question

What is the output of the following program?

1. 2
2. 3
3. 4
4. 5
Question

What is the output of the following program?

1. 2
2. 3
3. 4
4. 5
Answer: Option 4 : 5

You might also like