The scope of a name refers to the portion of a program in which an identifier can
be accessed. In C, identifiers may have local scope or global scope.
A variable declared inside a function has local scope and can be accessed only
within that function. A variable declared outside all functions has global scope
and can be accessed by all functions in the program. Understanding scope is
essential for avoiding naming conflicts and ensuring correct data access.
be accessed. In C, identifiers may have local scope or global scope.
A variable declared inside a function has local scope and can be accessed only
within that function. A variable declared outside all functions has global scope
and can be accessed by all functions in the program. Understanding scope is
essential for avoiding naming conflicts and ensuring correct data access.
int factoryLimit = 100; // global
void produce() {
int localTin = 5; // local
}