बिजनेस मार्केटिंग का लो कॉस्ट फंडा , अपने मोबाइल से ऑटो sms भेजकर मार्केटिंग करे विजिट करे http://autotextsms.com/ बिजनेस मार्केटिंग का लो कॉस्ट फंडा http://autotextsms.com/

Search This Blog

Translate

c storage classes,

   c storage classes,explain storage classes in c, storage classes in c language with examples, define storage classes in c,storage classes in c programming,storage classes in c with examples, storage classes in c with examples, static storage class, register storage class,auto storage class, extern storage class,automatic storage class, external storage class,explain storage classes,define storage class,auto storage class in c, storage classes in c with example,extern storage class in c, static storage class in c, register storage class in c, what are the storage classes in c, c storage class, storage classes c, explain storage classes in c language,c programming storage classes,what is class in c programming, storage class in c programming,classes in c programming

 

Explain Storage Classes in C,

Automatic storage class, Register storage class, Static storage class
,External storage class, how to understand storage classes in c programming chart trick


 

Explain Storage Classes in C?

Define storage classes in c?

Every variable not only has a data type but also have a storage class. If don't specify any storage class of a variable in its declaration, the compiler will assume a storage class depending on the context in which the variable is used. Thus, variables have certain default storage classes. A variable name identifies some physical location within the computer where the string of bits representing the variable value is stored. There are basically two kinds of locations in a computer where such a value may be kept memory and CPU registers. It is the variable's storage class, which determines in which of these two locations the value is stored.
A variable storage class tells us

1) Where the variable would be stored.

2) What will be the initial value of the variable, if the initial value is not specifically assigned (i.e, the default initial value).

3) What is the scope of the variable, i.e., in which functions the value of the variable would be available.

4) What is the life of the variables; i.e., how long would the variable exist.

There are four storage classes in C.

a) Automatic storage class

b) Register storage class

c) Static storage class

d) External storage class


a) Automatic storage class:- These variables comes into existence whenever and wherever the variable is declared. These variables are also called as local variables, because these are available local to a function. The storage is in the memory and it has a default value, which is a garbage value. It is local to the block in which it has been declared and it life is till the control remains within the block in which the variable is defined. The key word used is 'auto'.

b) Register storage class:-The storage of this type of variables is in the CPU registers. It has a garbage value initially. The scope of the variable is it is local to the block in which the variable is defined. Its life is till the control remains in the block in which it is defined. A value stored in a CPU register cal always be accessed faster than the one which is stored in memory. Therefore, if a variable is used at many places in a program it is better to declare its storage class as register. A good example of frequently used variables is loop counters. The key word used is 'register'.

c) Static storage class:-The storage is in the memory and default initial value is zero. It is local to the block in which it has been defined. The value of the variable persists between different function calls. The value will not disappear once the function in which it has been declared becomes inactive. It is unavailable only when you come out the program. The key word used is 'static'.

main(){  value();  value ();  value();  getch(); }


value()
{
   static int a=5;
   a=a+2;
   printf("\n%d",a);
}

The output of the program is not 7,7,7 but it is, 7,9,11.

a)    Extern storage class:-The variable has a storage in the memory. Default initial value is zero. The scope of the variable is global. It is present as long as the program execution comes to an end. The keyword used is 'extern'.

class
Automatic
Register
Static

External
1.variable stored
memory

CPU registers.
memory
memory
2.Default value
garbage
garbage 
Zero
Zero
3.scope of the variable
It is local to the block in which it has been declared
is it is local to the block in which the variable is defined.
It is local to the block in which it has been defined
scope of the variable is global
4.life of the variables
life is till the control remains within the block in which the variable is defined
Its life is till the control remains in the block in which it is defined.
value of variable persists between different function calls
It is present as long as the program execution comes to an end
5.Keyword
'auto'.
'register'.
‘static’
‘extern’


c storage classes,explain storage classes in c, storage classes in c language with examples, define storage classes in c,storage classes in c programming,storage classes in c with examples, storage classes in c with examples, static storage class, register storage class,auto storage class, extern storage class,automatic storage class, external storage class,explain storage classes,define storage class,auto storage class in c, storage classes in c with example,extern storage class in c, static storage class in c, register storage class in c, what are the storage classes in c, c storage class, storage classes c, explain storage classes in c language,c programming storage classes,what is class in c programming, storage class in c programming,classes in c programming

C Program example List