91-9990449935 0120-4256464 |
Storage Classes in CStorage classes are used to define scope and life time of a variable. There are four storage classes in C programming.
1) autoThe auto keyword is applied to all local variables automatically. It is the default storage class that is why it is known as automatic variable. Output: 10 10 2) registerThe register variable allocates memory in register than RAM. Its size is same of register size. It has a faster access than other variables. It is recommended to use register variable only for quick access such as in counter. Note: We can't get the address of register variable.3) staticThe static variable is initialized only once and exists till the end of the program. It retains its value between multiple functions call. The static variable has the default value 0 which is provided by compiler. Output: i= 1 and j= 1 i= 2 and j= 1 i= 3 and j= 1 4) externThe extern variable is visible to all the programs. It is used if two ore more files are sharing same variable or function.
Next TopicArray in C
|