Scope Static and Dynamic: Presented By-: Prateek Katiyar ROLL NO.-: 1683910030 Rajkiya Engineering College Kannauj
Scope Static and Dynamic: Presented By-: Prateek Katiyar ROLL NO.-: 1683910030 Rajkiya Engineering College Kannauj
DYNAMIC SCOPE
STATIC SCOPE
:: Also called lexical scoping
:: If a variable name’s scope is a certain function, then it’s
scope is the program text of the function definition:
within that text, the variable name exists, and is bound
to it’s variable, but outside that text, the variable name
does not exist.
:: In static scoping the compiler first searches in the
current block, then in the surrounding blocks
successively and finally in the global variables.
C program to demonstrate
static scope
#include<stdio.h>
int x = 10;
int f()
{
return x;
}
int g()
{