-->

Sunday, July 14, 2019

Storage classes in c




Storage classes in c

Storage classes in c
Storage classes in c



Storage Classes in C  are used to describe the features of a variable/function. These features basically include the scope, visibility and life-time which help us to trace the existence of a particular variable during the runtime of a program.

So, storage class signifies 4 things:

1.     Storage/ Location : where the variable is stored.
2.     Default value : what value would it hold if it is not initialized.
3.     Scope : where the variable is would be available.
4.    Life : how long would the variable be available. 

There are four type of storage classes in C.

1.     Automatic storage class.

2.     Register storage class.

3.     Static storage class.

4.     External  storage class.



Automatic storage class.

Keyword : auto
Storage : Memory.
Default value : garbage (unpredictable value).
Scope: local to block.
Life: till control is in the block in which variable is defined .

Register storage class.

Keyword : register.
Storage : CPU register (internal memory of microprocessor.).
Default value : garbage .
Scope: local to block.
Life: till control is in the block in which variable is defined.

Static storage class.

Keyword : static.
Storage : Memory.
Default value : zero/0
Scope: local to block.
Life: till the execution of program does not end.

External storage class.

Keyword : extern.
Storage : Memory.
Default value : zero/0.
Scope: global (whole the program).
 Life: till the execution of program does not end.

When we storage classes?

Register -for frequently used variable.
Static – if variable is to live across function calls.
External – if variable is required by all functions.
Automatic – All storage class.

 
Storage classes in c,storage class ,
Storage classes in c




Visit Our Website Link Here:https://www.digitalakhbar.co.in/
https://www.digitalakhbar.co.in/

           < previous page                                                                             Next page >


0 Comments:

Post a Comment