LearnFrenzy
Sign in Take a free test

C Variables · Variables MCQ · Question 7

Scope of a variable declared inside a block in C Answer, explanation & discussion

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

Where can a variable declared inside { … } be used?

  • A Anywhere in the function
  • B From its declaration to the end of that block Correct
  • C Anywhere in the file
  • D Only on the next line
Correct Answer: Option B

Block scope starts at the point of declaration (not at the opening brace) and ends at the closing brace. Inner blocks can see it unless they declare a variable with the same name.

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