LearnFrenzy
Sign in Take a free test

Arrays and Vectors · Arrays and Vectors MCQ · Question 20

Value of an uninitialized local array Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 20 Back to Exercise

What does int a[3]; declared inside a function contain?

  • A Three zeros
  • B Indeterminate (garbage) values – reading them is undefined behaviour Correct
  • C Three ones
  • D It does not compile
Correct Answer: Option B

Write int a[3]{}; to zero it. Global and static arrays, by contrast, are zero-initialized automatically.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links