1/4
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Global Scope
Variable defined outside a function, and outside a class
automatically initialized to 0
can be accessed by all functions
Local Scope
inside a function, formal parameter list, or inside a block
only exists in the respective one
destroyed when function returns
Block scope
inside if/while/etc.
destroyed when loop/block finishes
is same variable name in same scope allowed?
no
must not have same var name in same scope
even if type is different
compiler error
if same variable name in nested scope, eg. int j; (inside function), int j; (inside function’s block)
it picks the one in the same block, and the one defined above