Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which of the following statements are correct about an array?

1. The array int num[26]; can store 26 elements.

2. The expression num[1] designates the very first element in the array.

3. It is necessary to initialize the array at the time of declaration.

4. The declaration num[SIZE] is allowed if SIZE is a macro.

  • A.1
  • B.1,4
  • C.2,3
  • D.2,4

Answer: B

Correct answer: 1,4

1 is true - int num[26]; holds 26 elements, with subscripts 0 to 25. 4 is true - a macro expands before compilation, so num[SIZE] is a constant bound. 2 is false: num[1] is the second element, since indexing starts at 0. 3 is false: an array need not be initialised at declaration, though an uninitialised automatic array holds junk.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.