2. Definition of “Scope Rule”
• The scope rules of a language decides in which part(s) of the program
a particular piece of code on data in item can be accessed
Basic four scope rules:
1. File scope
2. Block scope
3. Function prototype scope
4. Function scope
3. • File scope: “ These Variable s are usually declare outside of all functions
and blocks at the top of program. They are also called global scope
variable.”
• Block scope: “A block scope is a set of statement enclosed within left and
right braces i.e. A variable declare d inside a block is accessible in the inner
block but not accessible outside the block i.e.only accessible to the block in
which variables are defined”
• Function prototype: “In these the scope of variables begin right after the
declaration in function parameter list and run to the and the declaration
list”
• Function scope: “A function scope begins at the opening of function and
end with the closing of it.
A function scope is applicable to the label only. A label declared is use as a
Target to goto statement and both goto and label statement must be in a
same function.