C++ language › Array in C++ › Question #24493
Single Choice Moderate

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

ID: #24493 Array in C++ 49 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

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.

Today: 0 answered · 0 correct
Save progress
Free account

Want to remember what you got wrong?

Create a free account in seconds to track your score, revisit mistakes and continue C++ language where you left off.

  • Save your progress & streak
  • Topic-wise quizzes & scores
  • Bookmark tricky questions
  • Printable MCQ sets
Practice smarterFree account · save progress
Sign up free

Share This Question

Challenge a friend or share with your study group.