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

Arrays Questions and Answers

Answer: D

Correct answer: Both (a) & (b)

(a) An entire array is passed simply by naming it, which hands over its base address. (b) A part can be passed just as easily, by passing the address of an interior element - f(&a[3], n) gives the function the tail of the array. (c) is false: since the function holds the caller’s address, changes it makes are not local - they are visible to the caller.

Please log in or register to report this question.

122.

Pick the correct answers
if x is an one dimensional array, then

Answer: D

Correct answer: both (b) & (c)

(c) is the definition of subscripting: x[i] is *(x + i). (b) follows from it - &x[i] is x + i, so dereferencing it gives the same element back. (a) is false: &x[i] equals x + i, not x + i - 1, which would be the previous element.

Please log in or register to report this question.

Answer: D

Correct answer: All of the above

All three are true. An array holds one type. An array may be a member of a structure, as a fixed-length name field commonly is. And an array of structures is entirely ordinary - a table of records is exactly that.

Please log in or register to report this question.

Answer: D

Correct answer: All of the above

All three reasons hold. A file persists after the program that wrote it ends, while an array vanishes with the process. A file need not be sized in advance, so no space is reserved and wasted. And the operating system provides tools - copy, search, sort, back up - that work on files and not on a program’s memory.

Please log in or register to report this question.

125.

Consider the declaration

char street[10] = "abcdefghi";

Choose the correct remark(s)

Answer: D

Correct answer: None of the above

All three remarks are false.

  • &street and street hold the same address - the start of the array - and differ only in type.
  • &street is perfectly meaningful: it has type char (*)[10].
  • Because of that type, &street + 1 advances 10 bytes while street + 1 advances 1, so the two differ.

Please log in or register to report this question.

Loading…
Tags: Arrays Questions and Answers || Arrays MCQ Questions and Answers || Arrays GK Questions and Answers || Arrays GK MCQ Questions || Arrays Multiple Choice Questions and Answers || Arrays GK || GK on Arrays || C Programming Questions and Answers || C Programming MCQ Questions and Answers || C Programming GK Questions and Answers || GK on C Programming