> Storage Classes Storage class is modifier or qualifier of data - TopicsExpress



          

> Storage Classes Storage class is modifier or qualifier of data types which decides: 1. In which area of memory a particular variable will be stored? 2. What is scope of variable? 3. What is visibility of variable? Meaning of scope is to check either variable is alive or dead. Visibility means accessibility. Up to witch part or area of a program, we can access a variable, that area or part is known as visibility of that variable. In c there are four types of storage class. They are: 1. auto 2. register 3. static 4. extern 1. auto: Automatic variables or auto variables are default storage class of local variable. An auto variable cannot be declared globally. (Why?) Properties of auto storage class. (1) Default initial value of auto variable is garbage. For example: #include int main(){ int i; auto char c; float f; printf("%d %c %f",i,c,f); return 0; } Output: Garbage Garbage Garbage (2)Visibility of auto variable is within the block where it has declared. For examples: (a) #include int main(){ int a=10; { int a=20; printf("%d",a); } printf(" %d",a); return 0; } Output: 20 10 Explanation: Visibility of variable a which has declared inside inner has block only within that block. (b) #include int main(){ { int a=20; printf("%d",a); } printf(" %d",a); //a is not visible here return 0; } Output: Compilation error Explanation: Visibility of variable a which has declared inside inner block has only within that block. (3) Scope of auto variable is within the block where it has declared. For example: (a) #include int main(){ int i; for(i=0;i
Posted on: Mon, 22 Jul 2013 07:54:12 +0000

Trending Topics



Recently Viewed Topics




© 2015