Category: Storage Classes

Compare Automatic, Register, Static and External Variables in C 2

Compare Automatic, Register, Static and External Variables in C

Let us understand the difference between various storage classes in C programming language. Below is the table that will show difference between Automatic, Register, Static and External Variables storage Classes in C. Feature Automatic Variable Register Variable Static Variable External Variable 1 Keyword Used auto register static extern 2 Storage Memory CPU registers Memory Memory 3 Default initial value Garbage Value Garbage Value Zero Value Zero Value 4 Scope Local to the block in which the variable is defined Local to the block in which the variable is defined Local to the block in which the variable is defined Global...

Storage Classes in C Programming Language 45

Storage Classes in C Programming Language

A storage class in C is an attribute that tells us where the variable would be stored, what will be the initial value of the variable if no value is assigned to that variable, life time of the variable and scope of the variable. There are four storage classes in C: 1) Automatic storage class 2) Register storage class 3) Static storage class 4) External storage class Automatic storage class in C: The keyword used for Automatic storage class is ‘auto’. The variable declared as auto is stored in the memory. Default value of that variable is garbage value. Scope...