Array in C++ Array in C++ Question #24493
MCQ Single Best Answer Moderate

QHow many elements does the array int x[20]; contain?

ID: #24493 Array in C++ 28 views
Question Info
#24493Q ID
ModerateDifficulty
Array in C++Topic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A 19
  • B 21
  • C 20
  • D 0
Correct Answer: Option C

Explanation

The declaration:

int x[20];

creates an array that can store 20 elements.

  • The number inside the brackets [20] specifies the total number of elements

  • Array indexing starts from 0

  • Valid indices range from 0 to 19

So even though the last index is 19, the array still contains 20 elements.

Correct Answer: C) 20

Description:
x[20] means the array size is 20, not 19.

Share This Question

Challenge a friend or share with your study group.