Published on: 12th Nov 2010    |   Last Updated on: 24th Nov 2011

Register Storage Class :

Syntax :

	register [data_type] [variable_name];
	
Example :

	register int a;
	

When the calculations are done in CPU, then the value of variables are transferred from main memory to CPU. Calculations are done and the final result is sent back to main memory. This leads to slowing down of processes.

Register variables occur in CPU and value of that register variable is stored in a register within that CPU. Thus, it increases the resultant speed of operations. There is no waste of time, getting variables from memory and sending it to back again.

It is not applicable for arrays, structures or pointers.

It cannot not used with static or external storage class.

Unary and address of (&) cannot be used with these variables as explicitly or implicitly.


Program :

/*  Program to demonstrate register storage class.
Creation Date : 09 Nov 2010 11:50:55 PM
Author : www.technoexam.com [Technowell, Sangli] */

#include <stdio.h> #include <conio.h> void main() { register int i=10; clrscr(); { register int i=20; printf("\n\t %d",i); } printf("\n\n\t %d",i); getch(); }

Output :



	20

	10_

Link this post on your Blog/Website :

Follow us on :   Technoexam on facebook Technoexam on twitter Technoexam on linkedin Technoexam on youtube