The illustration shows some lines of code numbered 1 through 25 with an annotation "Local and Global scope are examples of Block scope. A variable can be directly accessed only within its scope." The code segment and the annotations are as follows:
"Block Scope Revisited #include <iostream>
using namespace std;
const double GLOBAL_CONST = 1.0;
int function1(int param);
int main()
{
int x;
double d = GLOBAL_CONST;
for (int i = 0; i < 10; i++)
{
x = function1(i);
}" with the lines from “double d = GLOBAL_CONST;” annotated as "Block scope: Variable i has scope from lines 13-16."
“return 0;
}" with the block within the “int main()” annotated as "Local scope to main: Variable x has scope from lines 10-18 and variable d has scope from lines 11-18."
"int function1(int param)
{
double y = GLOBAL_CONST;
...
return 0;
}" annotated as "Local scope to function1: Variable param has scope from lines 20-25 and variable y has scope from lines 22-25." The code from line 4 till 25 is annotated as "Global scope: The constant GLOBAL_CONST has scope from lines 4-25 and the function function1 has scope from lines 6-25."