Slideshow

Monday, 25 February 2013


What do you understand by scope, lifetime and visibility of the variables? (6)
Ans:

Scope, Visibility and Lifetime of variables:
The scope of a variable determines the region of the program in which it is known.
An identifier's "visibility" determines the portions of the program in which it can be
referenced—its "scope." An identifier is visible only in portions of a program
encompassed by its "scope," which may be limited to the file, function or block in
which it appears.
File scope: The variables and functions with file scope appear outside any block or
list of parameters and is accessible from any place in the translation unit after its
declaration. Identifier names with file scope are often called "global" or "external."
The scope of a global identifier begins at the point of its definition or declaration
and terminates at the end of the translation unit. A function has file scope.
Function scope: A label is the only kind of identifier that has function scope. A
label is declared implicitly by its use in a statement. Label names must be unique
within a function however a label having the same name in two different functions
is allowed.
Block scope: The variables with block scope appear inside a block or within the list
of formal parameter declarations in a function definition. It is visible only from the
point of its declaration or definition to the end of the block containing its
declaration or definition.
Q.130 What is the smallest value of

No comments:

Post a Comment