Register Variable

Register Variable:

• These are also local variables, but stored in register memory.
• these variables will be accessed very faster than the normal variables because they are stored in register memory rather than main memory.
• But, only limited variables may be used as register since register size is very low. ( 32 bits,16 bits or 64 bits)

Example

#include<stdio.h>

int main()

{

register int p;

int arr1[5];// declaring array

arr1[0] = 10;// Initializing array

arr1[1] = 20;

arr1[2] = 30;

arr1[3] = 40;

arr1[4] = 50;

for (p=0;p<5;p++)

{

// Accessing each variable

printf(“value of arr1[%d] is %d \n”, p, arr1[p]);

}

return 0;

}

Output

value of arr1[0] is 10

value of arr1[1] is 20

value of ar1r[2] is 30

value of arr1[3] is 40

value of arr1[4] is 50

Leave a Reply

Your email address will not be published. Required fields are marked *