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!