SlideShare a Scribd company logo
Storage Classes
in C
Introduction
 Variables declared in C programs are
different than other programming
languages.
 Can use the same variable names in the
C program in separate blocks.
 When we declare a variable,it is
available only to a specific part or block
of the program.
 Remaining block or other functions
cannot access the variable.
 Variables declared within functions are
called local variables and those declared
outside are called external or global
variables.
Definition
Scope of variables:
 The area or scope of the C program from
where the variable can be accessed.
 The area or scope of the variable
depends on its storage class i.e. Where
and how it is declared.
The storage class of a variable tells the
compiler:
i)the storage area of the variable
ii)the initial value of the variable.
Iii)the scope of the variable.
Iv) the life of the variable i.e. How long the
variable would be active in the program.
 Variables declared in C can have any
one of the four storage classes:
Automatic
External
Static
Register
Lifetime of a Variable
 Every variable has a lifetime i.e. Its time
duration during which its status is active
in the program.
 The time gap between its declaration
and ckeanup.
 The lifetime depends upon the storage
class.
 For eg,auto variable gets destroyed
immediately when the function execution
is over,whereas static variable remains in
the memory.
Visibility of a Variable
 It defines the scope of a variable.
 The scope is of two types:
◦ Local scope
◦ Global scope
Global is recognized throughout the
program,whereas the local variable scope is
limited to the declaration block
Automatic variables
 The auto keyword is applied to all
local variables automatically.
 It is the default storage class that is
why it is known as automatic variable.
 the scope of the variable is local to the
block in which it is defined,available
only to the current block or program.
 The vanish after the block of code
finishes executing.
Example:
Register Variables
 The register variable allocates
memory in register than RAM.
 It has a faster access than other
variables.
 CPU registers are limited,hence
cannot declare more register
variables.
 It is recommended to use register
variable only for quick access such as
in counter.
Note: We can't get the address of
Example
void main()
{
register int m=1;
clrscr();
for (;m<=5;m++)
printf(“t %d”,m);
}
1 2 3 4 5
Static variables
 The static variable is initialized only
once and exists till the end of the
program.
 It retains its value between multiple
functions call.
 The static variable has the default
value 0 which is provided by
compiler,initialised once,it is never
reinitialized.
 Can be used to count how many times
Example
External Variable
 The extern variable is visible to all the
programs.
 It is used if two or more files are
sharing same variable or function.
 In case in aprogram where both
external and auto variables have been
declared with the same name,the first
priority is given to the auto variable.
 Variable defined at other place,other
than the place where it is declared.
Example:
int j=4;
void main() Output:
{
extern int j;
clrscr();
j=j*3;
printf(“ j=%d”,j);
fun();
printf(“n j=%d”,j);
}
fun()
{
j=j*j;
}
J=12
J=144

More Related Content

What's hot

Functions in C
Functions in CFunctions in C
Functions in C
Kamal Acharya
 
User defined functions in C
User defined functions in CUser defined functions in C
User defined functions in C
Harendra Singh
 
Storage classes in C
Storage classes in CStorage classes in C
Storage classes in C
Nitesh Bichwani
 
Unit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in CUnit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in C
Sowmya Jyothi
 
Storage classes
Storage classesStorage classes
Storage classes
Leela Koneru
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
tanmaymodi4
 
STORAGE CLASSES
STORAGE CLASSESSTORAGE CLASSES
STORAGE CLASSES
sathish sak
 
C functions
C functionsC functions
Inline function
Inline functionInline function
Inline functionTech_MX
 
INLINE FUNCTION IN C++
INLINE FUNCTION IN C++INLINE FUNCTION IN C++
INLINE FUNCTION IN C++
Vraj Patel
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++
HalaiHansaika
 
Switch case in C++
Switch case in C++Switch case in C++
Switch case in C++
Barani Govindarajan
 
Conditional Statement in C Language
Conditional Statement in C LanguageConditional Statement in C Language
Conditional Statement in C Language
Shaina Arora
 
Control statements in c
Control statements in cControl statements in c
Control statements in c
Sathish Narayanan
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programming
TejaswiB4
 
Loops c++
Loops c++Loops c++
Loops c++
Shivani Singh
 
Storage Class in C Progrmming
Storage Class in C Progrmming Storage Class in C Progrmming
Storage Class in C Progrmming
Kamal Acharya
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
Shuvongkor Barman
 
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
 FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM) FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
Mansi Tyagi
 

What's hot (20)

Functions in C
Functions in CFunctions in C
Functions in C
 
User defined functions in C
User defined functions in CUser defined functions in C
User defined functions in C
 
Storage classes in C
Storage classes in CStorage classes in C
Storage classes in C
 
Unit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in CUnit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in C
 
Storage classes
Storage classesStorage classes
Storage classes
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
 
STORAGE CLASSES
STORAGE CLASSESSTORAGE CLASSES
STORAGE CLASSES
 
C functions
C functionsC functions
C functions
 
Inline function
Inline functionInline function
Inline function
 
INLINE FUNCTION IN C++
INLINE FUNCTION IN C++INLINE FUNCTION IN C++
INLINE FUNCTION IN C++
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++
 
Switch case in C++
Switch case in C++Switch case in C++
Switch case in C++
 
Conditional Statement in C Language
Conditional Statement in C LanguageConditional Statement in C Language
Conditional Statement in C Language
 
Control statements in c
Control statements in cControl statements in c
Control statements in c
 
Function in C program
Function in C programFunction in C program
Function in C program
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programming
 
Loops c++
Loops c++Loops c++
Loops c++
 
Storage Class in C Progrmming
Storage Class in C Progrmming Storage Class in C Progrmming
Storage Class in C Progrmming
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
 
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
 FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM) FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
 

Similar to Storage classes in c language

Storage classes
Storage classesStorage classes
Storage classes
priyanka jain
 
Storage classes
Storage classesStorage classes
Storage classes
UTTAM VERMA
 
Storage class
Storage classStorage class
Storage class
Kalaikumar Thangapandi
 
Storage classes
Storage classesStorage classes
Storage classes
Puneet Rajput
 
Storage classess of C progamming
Storage classess of C progamming Storage classess of C progamming
Storage classess of C progamming
Appili Vamsi Krishna
 
Storage Class Specifiers in C++
Storage Class Specifiers in C++Storage Class Specifiers in C++
Storage Class Specifiers in C++
Reddhi Basu
 
Latest C Interview Questions and Answers
Latest C Interview Questions and AnswersLatest C Interview Questions and Answers
Latest C Interview Questions and Answers
DaisyWatson5
 
Advanced C Programming Notes
Advanced C Programming NotesAdvanced C Programming Notes
Advanced C Programming Notes
Leslie Schulte
 
Storage Class Specifiers
Storage Class SpecifiersStorage Class Specifiers
Storage Class Specifiers
Reddhi Basu
 
Storage classes
Storage classesStorage classes
Storage classes
Praveen M Jigajinni
 
STORAGE CLASS.pptx
STORAGE CLASS.pptxSTORAGE CLASS.pptx
STORAGE CLASS.pptx
BU210535JeevanKishor
 
Storage_classes_and_Scope_rules.pptx
Storage_classes_and_Scope_rules.pptxStorage_classes_and_Scope_rules.pptx
Storage_classes_and_Scope_rules.pptx
CheriviralaNikhil
 
Lecture 13 - Storage Classes
Lecture 13 - Storage ClassesLecture 13 - Storage Classes
Lecture 13 - Storage Classes
Md. Imran Hossain Showrov
 
What is storage class
What is storage classWhat is storage class
What is storage classIsha Aggarwal
 
5.program structure
5.program structure5.program structure
5.program structure
Shankar Gangaju
 
C programming session7
C programming  session7C programming  session7
C programming session7
Keroles karam khalil
 
C programming session7
C programming  session7C programming  session7
C programming session7
Keroles karam khalil
 

Similar to Storage classes in c language (20)

Storage classes
Storage classesStorage classes
Storage classes
 
Storage classes
Storage classesStorage classes
Storage classes
 
Storage class
Storage classStorage class
Storage class
 
Storage classes
Storage classesStorage classes
Storage classes
 
Storage classess of C progamming
Storage classess of C progamming Storage classess of C progamming
Storage classess of C progamming
 
Storage Class Specifiers in C++
Storage Class Specifiers in C++Storage Class Specifiers in C++
Storage Class Specifiers in C++
 
Storage classes
Storage classesStorage classes
Storage classes
 
Latest C Interview Questions and Answers
Latest C Interview Questions and AnswersLatest C Interview Questions and Answers
Latest C Interview Questions and Answers
 
Advanced C Programming Notes
Advanced C Programming NotesAdvanced C Programming Notes
Advanced C Programming Notes
 
Storage Class Specifiers
Storage Class SpecifiersStorage Class Specifiers
Storage Class Specifiers
 
Storage classes
Storage classesStorage classes
Storage classes
 
STORAGE CLASS.pptx
STORAGE CLASS.pptxSTORAGE CLASS.pptx
STORAGE CLASS.pptx
 
Storage_classes_and_Scope_rules.pptx
Storage_classes_and_Scope_rules.pptxStorage_classes_and_Scope_rules.pptx
Storage_classes_and_Scope_rules.pptx
 
Lecture 13 - Storage Classes
Lecture 13 - Storage ClassesLecture 13 - Storage Classes
Lecture 13 - Storage Classes
 
What is storage class
What is storage classWhat is storage class
What is storage class
 
5.program structure
5.program structure5.program structure
5.program structure
 
C programming session7
C programming  session7C programming  session7
C programming session7
 
C programming session7
C programming  session7C programming  session7
C programming session7
 
01 Variables
01 Variables01 Variables
01 Variables
 
Ch07
Ch07Ch07
Ch07
 

More from tanmaymodi4

Cryptocurrency
CryptocurrencyCryptocurrency
Cryptocurrency
tanmaymodi4
 
Pointers in c v5 12102017 1
Pointers in c v5 12102017 1Pointers in c v5 12102017 1
Pointers in c v5 12102017 1
tanmaymodi4
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
tanmaymodi4
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
tanmaymodi4
 
Dynamic memory allocation in c language
Dynamic memory allocation in c languageDynamic memory allocation in c language
Dynamic memory allocation in c language
tanmaymodi4
 
Arrays in c language
Arrays in c languageArrays in c language
Arrays in c language
tanmaymodi4
 
Decision statements in c language
Decision statements in c languageDecision statements in c language
Decision statements in c language
tanmaymodi4
 
Preprocessor directives in c language
Preprocessor directives in c languagePreprocessor directives in c language
Preprocessor directives in c language
tanmaymodi4
 
Structures in c language
Structures in c languageStructures in c language
Structures in c language
tanmaymodi4
 
Union in c language
Union  in c languageUnion  in c language
Union in c language
tanmaymodi4
 

More from tanmaymodi4 (10)

Cryptocurrency
CryptocurrencyCryptocurrency
Cryptocurrency
 
Pointers in c v5 12102017 1
Pointers in c v5 12102017 1Pointers in c v5 12102017 1
Pointers in c v5 12102017 1
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
 
Dynamic memory allocation in c language
Dynamic memory allocation in c languageDynamic memory allocation in c language
Dynamic memory allocation in c language
 
Arrays in c language
Arrays in c languageArrays in c language
Arrays in c language
 
Decision statements in c language
Decision statements in c languageDecision statements in c language
Decision statements in c language
 
Preprocessor directives in c language
Preprocessor directives in c languagePreprocessor directives in c language
Preprocessor directives in c language
 
Structures in c language
Structures in c languageStructures in c language
Structures in c language
 
Union in c language
Union  in c languageUnion  in c language
Union in c language
 

Recently uploaded

Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 

Recently uploaded (20)

Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 

Storage classes in c language

  • 2. Introduction  Variables declared in C programs are different than other programming languages.  Can use the same variable names in the C program in separate blocks.  When we declare a variable,it is available only to a specific part or block of the program.  Remaining block or other functions cannot access the variable.  Variables declared within functions are called local variables and those declared outside are called external or global variables.
  • 3. Definition Scope of variables:  The area or scope of the C program from where the variable can be accessed.  The area or scope of the variable depends on its storage class i.e. Where and how it is declared. The storage class of a variable tells the compiler: i)the storage area of the variable ii)the initial value of the variable. Iii)the scope of the variable. Iv) the life of the variable i.e. How long the variable would be active in the program.
  • 4.  Variables declared in C can have any one of the four storage classes: Automatic External Static Register
  • 5. Lifetime of a Variable  Every variable has a lifetime i.e. Its time duration during which its status is active in the program.  The time gap between its declaration and ckeanup.  The lifetime depends upon the storage class.  For eg,auto variable gets destroyed immediately when the function execution is over,whereas static variable remains in the memory.
  • 6. Visibility of a Variable  It defines the scope of a variable.  The scope is of two types: ◦ Local scope ◦ Global scope Global is recognized throughout the program,whereas the local variable scope is limited to the declaration block
  • 7.
  • 8. Automatic variables  The auto keyword is applied to all local variables automatically.  It is the default storage class that is why it is known as automatic variable.  the scope of the variable is local to the block in which it is defined,available only to the current block or program.  The vanish after the block of code finishes executing.
  • 10. Register Variables  The register variable allocates memory in register than RAM.  It has a faster access than other variables.  CPU registers are limited,hence cannot declare more register variables.  It is recommended to use register variable only for quick access such as in counter. Note: We can't get the address of
  • 11. Example void main() { register int m=1; clrscr(); for (;m<=5;m++) printf(“t %d”,m); } 1 2 3 4 5
  • 12. Static variables  The static variable is initialized only once and exists till the end of the program.  It retains its value between multiple functions call.  The static variable has the default value 0 which is provided by compiler,initialised once,it is never reinitialized.  Can be used to count how many times
  • 14. External Variable  The extern variable is visible to all the programs.  It is used if two or more files are sharing same variable or function.  In case in aprogram where both external and auto variables have been declared with the same name,the first priority is given to the auto variable.  Variable defined at other place,other than the place where it is declared.
  • 15. Example: int j=4; void main() Output: { extern int j; clrscr(); j=j*3; printf(“ j=%d”,j); fun(); printf(“n j=%d”,j); } fun() { j=j*j; } J=12 J=144