Wednesday, May 13, 2009

Declaration of Storage Class

Variables in C have not only the data type but also storage class that provides information about their location and visibility. The storage class divides the portion of the program within which the variables are recognized.

auto : It is a local variable known only to the function in which it is declared. Auto is the default storage class.

static : Local variable which exists and retains its value even after the control is transferred to the calling function.

extern : Global variable known to all functions in the file

register : Social variables which are stored in the register.



Defining Symbolic Constants
A symbolic constant value can be defined as a preprocessor statement and used in the program as any other constant value. The general form of a symbolic constant is

# define symbolic_name value of constant

Valid examples of constant definitions are :

# define marks 100
# define total 50
# define pi 3.14159

These values may appear anywhere in the program, but must come before it is referenced in the program.

It is a standard practice to place them at the beginning of the program.

No comments:

Post a Comment