Ques : What is External (Global) Variables ?

, , No Comments

 These are not confined to a single function. Their scope ranges from the point of declaration to the entire remaining program. Therefore, their scope may be the entire program or two or more functions depending upon where they are declared.


Points to remember:
• These are global and can be accessed by any function within its scope.
Therefore value may be assigned in one and can be written in another.
• There is difference in external variable definition and declaration.
• External Definition is the same as any variable declaration:

           • Usually lies outside or before the function accessing it.

• It allocates storage space required.
• Initial values can be assigned.
• The external specifier is not required in external variable definition.
• A declaration is required if the external variable definition comes after the function definition.
• A declaration begins with an external specifier.
• Only when external variable is defined is the storage space allocated.
• External variables can be assigned initial values as a part of variable definitions, but the values must be constants rather than expressions.
• If initial value is not included then it is automatically assigned a va

0 टिप्पणियाँ:

Post a Comment