Professional Documents
Culture Documents
auto
Storage Location - Memory
- Garbage Value - Local to the block in which the variable is defined. - Till the control remains within the block in which the variable is defined.
Example: auto int a,b; #include<stdio.h> #include<conio.h> main() { auto int a; clrscr(); printf (%d,a); getch() }
register
Storage Location CPU register Initial Value Scope Life - Garbage Value - Local to the block in which the variable is defined. - Till the control remains within the block in which the variable is defined.
A value stored in a CPU register can be accessed faster than the one which is stored in memory.
Example: register int a,b; #include<stdio.h> #include<conio.h> main() { register int a; clrscr(); printf(%d,a); getch() }
static
Storage Location - Memory Initial Value - Zero Scope - Local to the block in which the variable is defined. Life - value of the variable persists b/w different function calls.
Example: static int a,b; #include<stdio.h> #include<conio.h> main() { increase(); increase(); increase(); } increase() { static int a=1; printf(%d,a); a=a+1; getch(); }
external
Storage Location Initial Value Scope Life - Memory - Zero - Global - As long as the programs execution doesnt come to an end.
Example: external int a,b; #include<stdio.h> #include<conio.h> external int a; main() { clrscr(); printf(%d,a); getch() }