Compilers Questions and Answers – Array Reference – 1

This set of Compilers Multiple Choice Questions & Answers (MCQs) focuses on “Array Reference – 1”.

1. Which of the following correctly declares an array?
a) Int array[ 10]
b) int array
c) array{10}
d) array array[ 10]
View Answer

Answer: a
Explanation: Correct declaration.

2. What is the index number of the last element of an array with 29 elements?
a) 29
b) 28
c) 0
d) Programmer-Defined
View Answer

Answer: b
Explanation: The indexing in an array starts with zero hence we can say that the element.

3. Which of the following is a two-dimensional array?
a) array array[20][20]
b) int array[20][20]
c) int array[20, 20]
d) char array[20]
View Answer

Answer: b
Explanation: Double dimensional arrays are declared in this format.
advertisement
advertisement

4. Which of the following correctly accesses the seventh element stored in tan?
a) tan[6]
b) tan[7]
c) tan(7)
d) tan
View Answer

Answer: a
Explanation: The index no 6.

5. Which of the following gives the memory address of the first element in array tan?
a) tan[0]
b) tan
c) &tan
d) tan [1]
View Answer

Answer: b
Explanation: The base address of the array is given by its name.

6. What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of array?
a) The compiler would report an error
b) May stop working abruptly if data gets overwritten
c) None of the mentioned
d) The element will be set to 0
View Answer

Answer: b
Explanation: It often happens that the program crashes.

7. What does the following declaration mean?

advertisement
 int (*a)[10] a

a) Pointer to an array
b) None of the mentioned
c) Array of 10 integers
d) Pointer to an array & Array of 10 integers
View Answer

Answer: a
Explanation: Points to array.
advertisement

8. What is the meaning of the following declaration?

Int arr[20]

a) Integer Array of size 20
b) None of the mentioned
c) Array of size 20
d) Array of size 20 that can have higher integer address
View Answer

Answer: a
Explanation: Declaration of an array.

9. What will be the size of below array elements?

int a[20]

a) 21
b) 22
c) 20
d) 19
View Answer

Answer: c
Explanation: The number in square brackets denotes size of an array.

10. What is meaning of the following?

Int *ptr[20]

a) Interger array of size 20 pointing to an integer Pointer
b) None of the mentioned
c) Array of integer pointer of size 20
d) All of the mentioned
View Answer

Answer: c
Explanation: Array of pointers to integers.

Sanfoundry Global Education & Learning Series – Compilers.

To practice all areas of Compilers, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

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.