This set of Compilers Multiple Choice Questions & Answers (MCQs) focuses on “Array Reference – 2”.
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’,’\0’}
View Answer
Explanation: 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
View Answer
Explanation: 2 [] brackets means a double dimensional array.
3. What will be output of the following code?
#include<stdio.h> void main() { char arr[7]="Network"; printf("%s",arr); }
a) Network
b) N
c) network
d) Garbage Value
View Answer
Explanation: Garbage value is printed.
4. What will be output of the following code?
#include<stdio.h> void main() { char arr[11]="The African Queen"; printf("%s",arr); }
a) The African Queen
b) The
c) Queen
d) Null
View Answer
Explanation: It gives a Null Value.
5. What will be output if you will execute following C code?
#include<stdio.h> void main() { char arr[20]="MysticRiver"; printf("%d",sizeof(arr)); }
a) 20
b) 11
c) 30
d) None of the mentioned
View Answer
Explanation: The size of array is 20.
6. What will be output if you will execute following C code?
#include<stdio.h> 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
View Answer
Explanation: No fixed value in [] brackets.
7. Comment on the following statement:
int (*a)[7];
a) An array “a” of pointers
b) A pointer “a” to an array
c) A ragged array
d) None of the mentioned
View Answer
Explanation: 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
View Answer
Explanation: 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
View Answer
Explanation: 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
View Answer
Explanation: 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
View Answer
Explanation: The base address is passed when the array is passed as an argument in a function.
Sanfoundry Global Education & Learning Series – Compilers.
To practice all areas of Compilers, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Check Computer Science Books
- Practice Computer Science MCQs
- Check Compiler Design Books
- Apply for Computer Science Internship
- Practice MCA MCQs