LearnFrenzy
Sign in Take a free test

C Variables · Variables MCQ · Question 1

Value of an uninitialised local variable in C Answer, explanation & discussion

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

What is the value of int count; declared inside a function, before it is assigned?

  • A 0
  • B 1
  • C Indeterminate (garbage) – reading it is a bug Correct
  • D -1
Correct Answer: Option C

Automatic variables are not initialised. Their memory holds whatever was there before, and using the value is undefined behaviour in many cases. Always initialise locals.

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