Thursday, 13 July 2017

Register Variable

Register Variable C Language


Register is a special type of storage medium for making variables in c language. When there is a need of access any variable very frequently like inside of loops. For increase of access time of a variable it can be take place direct on register. If a variable is on a register then its take less time compare to access a variable form memory because register is a part of CPU.
So for increase C Program performance , you can use register variable but keep in mind when a request generated for register variable it pass to system if demanded register is free on desire time then variable take place on register otherwise it will be consider as normal variable and take place on memory.
Syntax :
Register <data_Type> Var_Name;
#include<stdio.h>
void main()
{
     register int i;
     i=1;
     while(i<=10)
     {
          printf("\n%d",i);
          i++;
     }
}