250+ TOP MCQs on Array Reference and Answers

Compilers Multiple Choice Questions on “Array Reference”.

1. In which way can SAM be stored in an array?
a) char name[]=”SAM”
b) char name[6]={‘S’,’A’,’M’}
c) char name[6]={“S”,”A”,”M”}
d) char name [6]={‘S’,’A’,’M’,’ ’}

Answer: d
Clarification: The array consists of the word SAM and also a NULL character.

2. Int RollNUm[30[4] is a?
a) 1-d Array
b) 3-D Array
c) 4- D Array
d) 2-D Array

Answer: d
Clarification: 2 [] brackets means a double dimensional array.

3. What will be output of the following code?

#include
void main()
{
    char arr[7]="Network";
    printf("%s",arr);
}

a) Network
b) N
c) network
d) Garbage Value

Answer: d
Clarification: Garbage value is printed.

4. What will be output of the following code?

#include
void main()
{
    char arr[11]="The African Queen";
    printf("%s",arr);
}

a) The African Queen
b) The
c) Queen
d) Null

Answer: d
Clarification: It gives a Null Value.

5. What will be output if you will execute following C code?

#include
void main()
{
    char arr[20]="MysticRiver";
    printf("%d",sizeof(arr));
}

a) 20
b) 11
c) 30
d) None of the mentioned

Answer: a
Clarification: The size of array is 20.

6. What will be output if you will execute following C code?

#include
void main(){
    int const SIZE=5;
    int expr;
    double value[SIZE]={2.0,4.0,6.0,8.0,10.0};
    expr=1|2|3|4;
    printf("%f",value[expr]);
}

a) 2.00000
b) 4.00000
c) 6.00000
d) Compilation error

Answer: d
Clarification: No fixed value in [] brackets.

7. Comment on the following statement:

a) An array “a” of pointers
b) A pointer “a” to an array
c) A ragged array
d) None of the mentioned

  250+ TOP MCQs on Non-Deterministic Finite Automata and Answers

Answer: b
Clarification: It is a pointer to array a.

8. Comment on the 2 arrays regarding P and Q:

int *a1[8];
int *(a3[8]);
P. Array of pointers
Q. Pointer to an array

a) a1 is P, a2 is Q
b) a1 is P, a2 is P
c) a1 is Q, a2 is P
d) a1 is Q, a2 is Q

Answer: b
Clarification: p =a1
And a3 is alo p.

8. Which of the following is not possible statically in C?
a) Jagged Array
b) Rectangular Array
c) Cuboidal Array
d) Multidimensional Array

Answer: a
Clarification: Jagged array is not possible.

9. What is the max no. of dimensions an array may have?
a) 2
b) 8
c) 20
d) No limit

Answer: d
Clarification: Dimension of an array can be any number.

10. Array passed as an argument to a function is interpreted as ______________
a) Address of the array
b) None of the mentioned
c) Base address
d) No. of elements of the array

Answer: c
Clarification: The base address is passed when the array is passed as an argument in a function.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top