Register storage class:

The location of the register storage class is memory. The default initial value is garbage value, which is unpredictable.  The variable will be alive until the block in which the variable is defined in under the phase of execution. The variable scope is up to the block in which it is defined.


#include <stdio.h>

int main()


  register int i=1;



return 0;




The scope is same as the auto storage class, works only inside the block in which it is defined.

This keyword is used mostly in the looping controllers etc. because; the accessing of variables stored in the registers is much faster than stored in the memory. The looping controllers need the variables every time after each iteration. So mostly register is used in that scenario.





The limitation with the register is with the size. We can only define the data types of the variable basing on the maximum size of the register.



If the size of the register is 16 bits, we cannot declare float, double like data types because, they may have size up to 4 and 8 bytes which is not sufficient. If we declare float and double, this may not any error because, the complier will consider them as the auto storage class.

Even though we declare the variable as the register, it may not necessarily taken the storage class as register, because the number of registers used in CPU are limited. If any of the register in not doing any work, it may take variable as register else it won’t take it.

Contributor's Info