001-003-013
Scope in Nested Blocks
Medium
Problem Description
Scope in Nested Blocks
Learning Objective: Understand variable scope between nested blocks
Overview
Declare variables in three levels of nested blocks and verify which variables are accessible at each level.
Specifications
- Level 1: Initialize variable
awith 1 - Level 2: Initialize variable
bwith 2 (inside Level 1) - Level 3: Initialize variable
cwith 3 (inside Level 2) - At Level 3, output sum of all variables
- At Level 2, output sum of
aandb - At Level 1, output only
a
Output Format
Level 3: a+b+c = 6
Level 2: a+b = 3
Level 1: a = 1
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
