Compilers Questions and Answers – Array Reference – 2

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

Answer: d
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

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

3. What will be output of the following code?

advertisement
advertisement
#include<stdio.h>
void main()
{
    char arr[7]="Network";
    printf("%s",arr);
}

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

Answer: d
Explanation: Garbage value is printed.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

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

Answer: d
Explanation: It gives a Null Value.
advertisement

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

advertisement
#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

Answer: a
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

Answer: d
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

Answer: b
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

Answer: b
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

Answer: a
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

Answer: d
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

Answer: c
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.

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.