SlideShare ist ein Scribd-Unternehmen logo
1 von 15
Storage
Classes( Characteristics of Variable )
Prepared By
Vishnu Sharma(MCA)
www.examengine.info
Prepared By Vishnu Sharma(MCA) for www.examengine.info
Meaning of Storage Class
Each variable declared in C contains not only its
data type but also it has a storage class specified
with it.
If user do not specify the storage class of a
variable , the compiler will assume its storage
class as default i.e. automatic .
Prepared By Vishnu Sharma(MCA) for www.examengine.info
Purpose of Storage Class
The storage class of a variable tells us about :-
I. Storage Place of Variable i.e. Memory or CPU Registers
II. Initial value of Variable
III. Scope of Variable
IV. Lifetime of Variable i.e. how long variable exists.
Prepared By Vishnu Sharma(MCA) for www.examengine.info
How Storage Class Declared ????
auto int a ,b ;
Storage
Class
Data Type Variable
Prepared By Vishnu Sharma(MCA) for www.examengine.info
Four Type of Storage Class in C
Language :-
 Automatic Storage Class ( Local Variables )
 Register Storage Class
 Static Storage Class
 External Storage Class
Prepared By Vishnu Sharma(MCA) for www.examengine.info
Automatic Storage Class
Characteristi
cs
Meaning
Storage Memory
Initial Value Garbage Value i.e. An Unpredictable Value.
Scope or
Visibility
Local or Visible in the Block in which it is declared.
Life Time It retains its value till it is in the block in which it is
declared.
This is the default storage class for all the variable . It always
reinitialize the value of variable .It is declared as : -
auto int a ;
Prepared By Vishnu Sharma(MCA) for www.examengine.info
Void main ( )
{
auto int i , j = 5 ;
int k ,m =10 ; // By Default Automatic
Storage Class
printf ( “ value of i = % d n value of j = %
d “ , i , j ) ;
printf ( “ value of k = % d n value of m = %
d “ , i , j ) ;
}
Value of i = 2009
Value of j = 5
Value of k = 1005
Value of m = 10
Garbage Value
Variable Value
Use of Automatic Storage Class
Prepared By Vishnu Sharma(MCA) for www.examengine.info
#include<stdio.h>
int main()
{
auto int i=1;
{
 auto int i=2;
 {
 auto int i=3;
 printf(“%d”,i);
 }
 printf(“%d”,i);
 } printf(“%d”,i);
 return 0;Prepared By Vishnu Sharma(MCA) for www.examengine.info
Use of Automatic Storage Class
void ck ( ) ;
void main( )
{
clrscr ( ) ;
ck ( ) ;
ck ( ) ;
ck ( ) ;
getch( ) ;
}
void ck ( )
{
int i = 0 ;
printf ( “nn Value of I ..%d”,i ) ;
i + + ;
}
Output
0
0
0
Prepared By Vishnu Sharma(MCA) for www.examengine.info
Register Storage Class
Characteristic
s
Meaning
Storage C P U Registers
Initial Value Garbage Value
Scope or
Visibility
Local to the Block in which it is declared
Life Time It retains its value till the control remains in the block
In this storage class , variable is stored in C P U Registers , just for the
sake of increase the execution speed of some variable of program. It is
declares as :-
register int a ;
Prepared By Vishnu Sharma(MCA) for www.examengine.info
Void main ( )
{
register int i ;
for ( i = 1 ; i < = 100 ; i + + )
{
printf ( “ n % d “ , i ) ;
}
}
Use of Register Storage Class
Prepared By Vishnu Sharma(MCA) for www.examengine.info
Static Storage Class
This storage class is used when a user want that a variable should retain its
value even after the execution of the function in which it is declared, then
this storage class is used . It is declared as follow :-
static int a ;
Characteristic
s
Meaning
Storage Memory
Initial Value Zero ( 0 )
Scope or
Visibility
Local to the block in which it is declared
Life Time It retains its value between the different functionPrepared By Vishnu Sharma(MCA) for www.examengine.info
Use of Static Storage Class
void ck ( ) ;
void main( )
{
clrscr ( ) ;
ck ( ) ;
ck ( ) ;
ck ( ) ;
getch( ) ;
}
void ck ( )
{
static int i = 0 ;
printf ( “nn Value of I ..%d”,i ) ;
i + + ;
}
Output
0
1
2
Prepared By Vishnu Sharma(MCA) for www.examengine.info
External Storage Class
Characteristic
s
Meaning
Storage Memory
Initial Value Zero ( 0 )
Scope or
Visibility
Global ( Visible in all the Program )
Life Time It retains its value through out the whole program
External variables are declared outside all functions i.e, at the beginning of
the program. Global variables should be available to all the functions with
the help of extern specifier. It is declared as follow : -
extern int a ;
Prepared By Vishnu Sharma(MCA) for www.examengine.info
Use of External Storage Class
extern int a = 10 ;
void ck ( ) ;
void main( )
{
int a = 5 ;
printf ( “ %d “ , a) ;
ck ( ) ;
getch ( ) ;
}
void ck ( )
{
a = a + 10 ;
printf ( “nn Value of a ..%d”,a ) ;
}
Output
5
20
Prepared By Vishnu Sharma(MCA) for www.examengine.info

Weitere ähnliche Inhalte

Was ist angesagt?

02 c++ Array Pointer
02 c++ Array Pointer02 c++ Array Pointer
02 c++ Array Pointer
Tareq Hasan
 

Was ist angesagt? (20)

Storage classes in c language
Storage classes in c languageStorage classes in c language
Storage classes in c language
 
Storage class
Storage classStorage class
Storage class
 
Storage Class in C Progrmming
Storage Class in C Progrmming Storage Class in C Progrmming
Storage Class in C Progrmming
 
Python : Functions
Python : FunctionsPython : Functions
Python : Functions
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions
 
Header files of c++ unit 3 -topic 3
Header files of c++ unit 3 -topic 3Header files of c++ unit 3 -topic 3
Header files of c++ unit 3 -topic 3
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
 
C++ Memory Management
C++ Memory ManagementC++ Memory Management
C++ Memory Management
 
STORAGE CLASSES
STORAGE CLASSESSTORAGE CLASSES
STORAGE CLASSES
 
Type casting in java
Type casting in javaType casting in java
Type casting in java
 
02 c++ Array Pointer
02 c++ Array Pointer02 c++ Array Pointer
02 c++ Array Pointer
 
Python Programming Essentials - M9 - String Formatting
Python Programming Essentials - M9 - String FormattingPython Programming Essentials - M9 - String Formatting
Python Programming Essentials - M9 - String Formatting
 
Type Casting in C++
Type Casting in C++Type Casting in C++
Type Casting in C++
 
Introduction to Input/Output Functions in C
Introduction to Input/Output Functions in CIntroduction to Input/Output Functions in C
Introduction to Input/Output Functions in C
 
The Joy of SciPy
The Joy of SciPyThe Joy of SciPy
The Joy of SciPy
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
 
C languaGE UNIT-1
C languaGE UNIT-1C languaGE UNIT-1
C languaGE UNIT-1
 
Functions in Python
Functions in PythonFunctions in Python
Functions in Python
 
Stream classes in C++
Stream classes in C++Stream classes in C++
Stream classes in C++
 

Ähnlich wie storage class

What is storage class
What is storage classWhat is storage class
What is storage class
Isha Aggarwal
 
presentation_functions_1443207686_140676.ppt
presentation_functions_1443207686_140676.pptpresentation_functions_1443207686_140676.ppt
presentation_functions_1443207686_140676.ppt
SandipPradhan23
 
Data structure scope of variables
Data structure scope of variablesData structure scope of variables
Data structure scope of variables
Saurav Kumar
 

Ähnlich wie storage class (20)

Storage class in C Language
Storage class in C LanguageStorage class in C Language
Storage class in C Language
 
Storage class
Storage classStorage class
Storage class
 
Java ppt Gandhi Ravi (gandhiri@gmail.com)
Java ppt  Gandhi Ravi  (gandhiri@gmail.com)Java ppt  Gandhi Ravi  (gandhiri@gmail.com)
Java ppt Gandhi Ravi (gandhiri@gmail.com)
 
from java to c
from java to cfrom java to c
from java to c
 
What is storage class
What is storage classWhat is storage class
What is storage class
 
Storage class
Storage classStorage class
Storage class
 
Storage class
Storage classStorage class
Storage class
 
Storage classes arrays & functions in C Language
Storage classes arrays & functions in C LanguageStorage classes arrays & functions in C Language
Storage classes arrays & functions in C Language
 
Pro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScriptPro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScript
 
Storage classes
Storage classesStorage classes
Storage classes
 
5.program structure
5.program structure5.program structure
5.program structure
 
presentation_functions_1443207686_140676.ppt
presentation_functions_1443207686_140676.pptpresentation_functions_1443207686_140676.ppt
presentation_functions_1443207686_140676.ppt
 
What is inheritance
What is inheritanceWhat is inheritance
What is inheritance
 
Java doc Pr ITM2
Java doc Pr ITM2Java doc Pr ITM2
Java doc Pr ITM2
 
Storage Class
Storage ClassStorage Class
Storage Class
 
Data structure scope of variables
Data structure scope of variablesData structure scope of variables
Data structure scope of variables
 
Lecture 13 - Storage Classes
Lecture 13 - Storage ClassesLecture 13 - Storage Classes
Lecture 13 - Storage Classes
 
Chap2 class,objects
Chap2 class,objectsChap2 class,objects
Chap2 class,objects
 
Advanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sirAdvanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sir
 
java_bba_21_vision academy_final.pdf
java_bba_21_vision academy_final.pdfjava_bba_21_vision academy_final.pdf
java_bba_21_vision academy_final.pdf
 

Mehr von student (20)

Logic Gates
Logic GatesLogic Gates
Logic Gates
 
Flipflops and Excitation tables of flipflops
Flipflops and Excitation tables of flipflopsFlipflops and Excitation tables of flipflops
Flipflops and Excitation tables of flipflops
 
Number Systems
Number SystemsNumber Systems
Number Systems
 
towers of hanoi
towers of hanoitowers of hanoi
towers of hanoi
 
header, circular and two way linked lists
header, circular and two way linked listsheader, circular and two way linked lists
header, circular and two way linked lists
 
Arrays Data Structure
Arrays Data StructureArrays Data Structure
Arrays Data Structure
 
Number Systems
Number SystemsNumber Systems
Number Systems
 
binary arithmetic rules
binary arithmetic rulesbinary arithmetic rules
binary arithmetic rules
 
BCD,GRAY and EXCESS 3 codes
BCD,GRAY and EXCESS 3 codesBCD,GRAY and EXCESS 3 codes
BCD,GRAY and EXCESS 3 codes
 
animals colours numbers idioms
animals colours numbers idiomsanimals colours numbers idioms
animals colours numbers idioms
 
irregular verbs
irregular verbsirregular verbs
irregular verbs
 
dc generator ece
dc generator ecedc generator ece
dc generator ece
 
INDUCTION MOTOR
INDUCTION MOTORINDUCTION MOTOR
INDUCTION MOTOR
 
structure and union
structure and unionstructure and union
structure and union
 
file handling1
file handling1file handling1
file handling1
 
direct and indirect band gap
direct and indirect band gapdirect and indirect band gap
direct and indirect band gap
 
hall effect
hall effecthall effect
hall effect
 
optics chapter_07_solution_manual
optics chapter_07_solution_manualoptics chapter_07_solution_manual
optics chapter_07_solution_manual
 
dyneins and kinesins
dyneins and kinesinsdyneins and kinesins
dyneins and kinesins
 
Structure and function of bacterial cells
Structure and function of bacterial cellsStructure and function of bacterial cells
Structure and function of bacterial cells
 

Kürzlich hochgeladen

Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
dlhescort
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Sheetaleventcompany
 
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
amitlee9823
 
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabiunwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
Abortion pills in Kuwait Cytotec pills in Kuwait
 
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
lizamodels9
 
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al MizharAl Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
allensay1
 

Kürzlich hochgeladen (20)

Phases of Negotiation .pptx
 Phases of Negotiation .pptx Phases of Negotiation .pptx
Phases of Negotiation .pptx
 
Falcon Invoice Discounting: The best investment platform in india for investors
Falcon Invoice Discounting: The best investment platform in india for investorsFalcon Invoice Discounting: The best investment platform in india for investors
Falcon Invoice Discounting: The best investment platform in india for investors
 
Organizational Transformation Lead with Culture
Organizational Transformation Lead with CultureOrganizational Transformation Lead with Culture
Organizational Transformation Lead with Culture
 
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
 
Famous Olympic Siblings from the 21st Century
Famous Olympic Siblings from the 21st CenturyFamous Olympic Siblings from the 21st Century
Famous Olympic Siblings from the 21st Century
 
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfDr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRLBAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
 
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
 
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
 
Malegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
Malegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort ServiceMalegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
Malegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
 
How to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League CityHow to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League City
 
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
 
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)Lundin Gold - Q1 2024 Conference Call Presentation (Revised)
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)
 
Marel Q1 2024 Investor Presentation from May 8, 2024
Marel Q1 2024 Investor Presentation from May 8, 2024Marel Q1 2024 Investor Presentation from May 8, 2024
Marel Q1 2024 Investor Presentation from May 8, 2024
 
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort ServiceEluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
 
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabiunwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
 
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
 
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al MizharAl Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
 

storage class

  • 1. Storage Classes( Characteristics of Variable ) Prepared By Vishnu Sharma(MCA) www.examengine.info Prepared By Vishnu Sharma(MCA) for www.examengine.info
  • 2. Meaning of Storage Class Each variable declared in C contains not only its data type but also it has a storage class specified with it. If user do not specify the storage class of a variable , the compiler will assume its storage class as default i.e. automatic . Prepared By Vishnu Sharma(MCA) for www.examengine.info
  • 3. Purpose of Storage Class The storage class of a variable tells us about :- I. Storage Place of Variable i.e. Memory or CPU Registers II. Initial value of Variable III. Scope of Variable IV. Lifetime of Variable i.e. how long variable exists. Prepared By Vishnu Sharma(MCA) for www.examengine.info
  • 4. How Storage Class Declared ???? auto int a ,b ; Storage Class Data Type Variable Prepared By Vishnu Sharma(MCA) for www.examengine.info
  • 5. Four Type of Storage Class in C Language :-  Automatic Storage Class ( Local Variables )  Register Storage Class  Static Storage Class  External Storage Class Prepared By Vishnu Sharma(MCA) for www.examengine.info
  • 6. Automatic Storage Class Characteristi cs Meaning Storage Memory Initial Value Garbage Value i.e. An Unpredictable Value. Scope or Visibility Local or Visible in the Block in which it is declared. Life Time It retains its value till it is in the block in which it is declared. This is the default storage class for all the variable . It always reinitialize the value of variable .It is declared as : - auto int a ; Prepared By Vishnu Sharma(MCA) for www.examengine.info
  • 7. Void main ( ) { auto int i , j = 5 ; int k ,m =10 ; // By Default Automatic Storage Class printf ( “ value of i = % d n value of j = % d “ , i , j ) ; printf ( “ value of k = % d n value of m = % d “ , i , j ) ; } Value of i = 2009 Value of j = 5 Value of k = 1005 Value of m = 10 Garbage Value Variable Value Use of Automatic Storage Class Prepared By Vishnu Sharma(MCA) for www.examengine.info
  • 8. #include<stdio.h> int main() { auto int i=1; {  auto int i=2;  {  auto int i=3;  printf(“%d”,i);  }  printf(“%d”,i);  } printf(“%d”,i);  return 0;Prepared By Vishnu Sharma(MCA) for www.examengine.info
  • 9. Use of Automatic Storage Class void ck ( ) ; void main( ) { clrscr ( ) ; ck ( ) ; ck ( ) ; ck ( ) ; getch( ) ; } void ck ( ) { int i = 0 ; printf ( “nn Value of I ..%d”,i ) ; i + + ; } Output 0 0 0 Prepared By Vishnu Sharma(MCA) for www.examengine.info
  • 10. Register Storage Class Characteristic s Meaning Storage C P U Registers Initial Value Garbage Value Scope or Visibility Local to the Block in which it is declared Life Time It retains its value till the control remains in the block In this storage class , variable is stored in C P U Registers , just for the sake of increase the execution speed of some variable of program. It is declares as :- register int a ; Prepared By Vishnu Sharma(MCA) for www.examengine.info
  • 11. Void main ( ) { register int i ; for ( i = 1 ; i < = 100 ; i + + ) { printf ( “ n % d “ , i ) ; } } Use of Register Storage Class Prepared By Vishnu Sharma(MCA) for www.examengine.info
  • 12. Static Storage Class This storage class is used when a user want that a variable should retain its value even after the execution of the function in which it is declared, then this storage class is used . It is declared as follow :- static int a ; Characteristic s Meaning Storage Memory Initial Value Zero ( 0 ) Scope or Visibility Local to the block in which it is declared Life Time It retains its value between the different functionPrepared By Vishnu Sharma(MCA) for www.examengine.info
  • 13. Use of Static Storage Class void ck ( ) ; void main( ) { clrscr ( ) ; ck ( ) ; ck ( ) ; ck ( ) ; getch( ) ; } void ck ( ) { static int i = 0 ; printf ( “nn Value of I ..%d”,i ) ; i + + ; } Output 0 1 2 Prepared By Vishnu Sharma(MCA) for www.examengine.info
  • 14. External Storage Class Characteristic s Meaning Storage Memory Initial Value Zero ( 0 ) Scope or Visibility Global ( Visible in all the Program ) Life Time It retains its value through out the whole program External variables are declared outside all functions i.e, at the beginning of the program. Global variables should be available to all the functions with the help of extern specifier. It is declared as follow : - extern int a ; Prepared By Vishnu Sharma(MCA) for www.examengine.info
  • 15. Use of External Storage Class extern int a = 10 ; void ck ( ) ; void main( ) { int a = 5 ; printf ( “ %d “ , a) ; ck ( ) ; getch ( ) ; } void ck ( ) { a = a + 10 ; printf ( “nn Value of a ..%d”,a ) ; } Output 5 20 Prepared By Vishnu Sharma(MCA) for www.examengine.info