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

Discussion

The C declaration
int b [100];
reserves ____________ successive memory locations,each large enough to contain single integer.

  • A.200
  • B.10,000
  • C.100
  • D.10

Answer: C

Correct answer: 100

int b[100]; declares an array of 100 elements, so it reserves 100 successive locations each large enough for one int.

The bytes occupied would be \( 100 \times \mathtt{sizeof(int)} \) - 400 on a typical implementation - but the question asks for locations each holding a single integer, which is the element count. Note also that the valid indices run from 0 to 99; using b[100] is the classic off-by-one error, and C performs no bounds checking to catch it.

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

Post your comment

Please log in or register to post a comment.