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

Storage classess of C progamming
Storage classess of C progamming Storage classess of C progamming
Storage classess of C progamming
Appili Vamsi Krishna
 
Lecture 11 - Functions
Lecture 11 - FunctionsLecture 11 - Functions
Lecture 11 - Functions
Md. Imran Hossain Showrov
 
STORAGE CLASSES
STORAGE CLASSESSTORAGE CLASSES
STORAGE CLASSES
sathish sak
 
C language
C languageC language
C language
Mohamed Bedair
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
Wingston
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programming
TejaswiB4
 
Storage Class Specifiers in C++
Storage Class Specifiers in C++Storage Class Specifiers in C++
Storage Class Specifiers in C++
Reddhi Basu
 
Storage class
Storage classStorage class
Storage class
Joy Forerver
 
Storage class in c
Storage class in cStorage class in c
Storage class in c
kash95
 
11 lec 11 storage class
11 lec 11 storage class11 lec 11 storage class
11 lec 11 storage classkapil078
 
C++ decision making
C++ decision makingC++ decision making
C++ decision making
Zohaib Ahmed
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.
Haard Shah
 
Decision statements in c language
Decision statements in c languageDecision statements in c language
Decision statements in c language
tanmaymodi4
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
tanmaymodi4
 
C language Unit 2 Slides, UPTU C language
C language Unit 2 Slides, UPTU C languageC language Unit 2 Slides, UPTU C language
C language Unit 2 Slides, UPTU C language
Rakesh Roshan
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
tanmaymodi4
 
C Prog. - Decision & Loop Controls
C Prog. - Decision & Loop ControlsC Prog. - Decision & Loop Controls
C Prog. - Decision & Loop Controlsvinay arora
 
C language presentation
C language presentationC language presentation
C language presentationbainspreet
 

What's hot (19)

Storage classess of C progamming
Storage classess of C progamming Storage classess of C progamming
Storage classess of C progamming
 
Lecture 11 - Functions
Lecture 11 - FunctionsLecture 11 - Functions
Lecture 11 - Functions
 
Storage classes
Storage classesStorage classes
Storage classes
 
STORAGE CLASSES
STORAGE CLASSESSTORAGE CLASSES
STORAGE CLASSES
 
C language
C languageC language
C language
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programming
 
Storage Class Specifiers in C++
Storage Class Specifiers in C++Storage Class Specifiers in C++
Storage Class Specifiers in C++
 
Storage class
Storage classStorage class
Storage class
 
Storage class in c
Storage class in cStorage class in c
Storage class in c
 
11 lec 11 storage class
11 lec 11 storage class11 lec 11 storage class
11 lec 11 storage class
 
C++ decision making
C++ decision makingC++ decision making
C++ decision making
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.
 
Decision statements in c language
Decision statements in c languageDecision statements in c language
Decision statements in c language
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
 
C language Unit 2 Slides, UPTU C language
C language Unit 2 Slides, UPTU C languageC language Unit 2 Slides, UPTU C language
C language Unit 2 Slides, UPTU C language
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
 
C Prog. - Decision & Loop Controls
C Prog. - Decision & Loop ControlsC Prog. - Decision & Loop Controls
C Prog. - Decision & Loop Controls
 
C language presentation
C language presentationC language presentation
C language presentation
 

Similar to Storage classes in c language

Storage classes
Storage classesStorage classes
Storage classes
priyanka jain
 
Storage Class in C Progrmming
Storage Class in C Progrmming Storage Class in C Progrmming
Storage Class in C Progrmming
Kamal Acharya
 
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
Leela Koneru
 
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
 
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
 
FUNCTION CPU
FUNCTION CPUFUNCTION CPU
FUNCTION CPU
Krushal Kakadia
 
C language updated
C language updatedC language updated
C language updated
Arafat Bin Reza
 

Similar to Storage classes in c language (20)

Storage classes
Storage classesStorage classes
Storage classes
 
Storage Class in C Progrmming
Storage Class in C Progrmming Storage Class in C Progrmming
Storage Class in C Progrmming
 
Storage classes
Storage classesStorage classes
Storage classes
 
Storage class
Storage classStorage class
Storage class
 
Storage classes
Storage classesStorage classes
Storage classes
 
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
 
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
 
FUNCTION CPU
FUNCTION CPUFUNCTION CPU
FUNCTION CPU
 
C language updated
C language updatedC language updated
C language updated
 

More from Tanmay Modi

Preprocessor directives in c laguage
Preprocessor directives in c laguagePreprocessor directives in c laguage
Preprocessor directives in c laguage
Tanmay Modi
 
Pointers in c language
Pointers in c languagePointers in c language
Pointers in c language
Tanmay Modi
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
Tanmay Modi
 
Generations of computers
Generations of computersGenerations of computers
Generations of computers
Tanmay Modi
 
Union in c language
Union in c languageUnion in c language
Union in c language
Tanmay Modi
 
Structures in c language
Structures in c languageStructures in c language
Structures in c language
Tanmay Modi
 
Operators inc c language
Operators inc c languageOperators inc c language
Operators inc c language
Tanmay Modi
 
Functions in c language
Functions in c languageFunctions in c language
Functions in c language
Tanmay Modi
 
Dynamic memory allocation in c language
Dynamic memory allocation in c languageDynamic memory allocation in c language
Dynamic memory allocation in c language
Tanmay Modi
 
Decision statements in c laguage
Decision statements in c laguageDecision statements in c laguage
Decision statements in c laguage
Tanmay Modi
 
Arrays in c v1 09102017
Arrays in c v1 09102017Arrays in c v1 09102017
Arrays in c v1 09102017
Tanmay Modi
 
Cryptocurrency
Cryptocurrency Cryptocurrency
Cryptocurrency
Tanmay Modi
 

More from Tanmay Modi (12)

Preprocessor directives in c laguage
Preprocessor directives in c laguagePreprocessor directives in c laguage
Preprocessor directives in c laguage
 
Pointers in c language
Pointers in c languagePointers in c language
Pointers in c language
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
 
Generations of computers
Generations of computersGenerations of computers
Generations of computers
 
Union in c language
Union in c languageUnion in c language
Union in c language
 
Structures in c language
Structures in c languageStructures in c language
Structures in c language
 
Operators inc c language
Operators inc c languageOperators inc c language
Operators inc c language
 
Functions in c language
Functions in c languageFunctions in c language
Functions 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
 
Decision statements in c laguage
Decision statements in c laguageDecision statements in c laguage
Decision statements in c laguage
 
Arrays in c v1 09102017
Arrays in c v1 09102017Arrays in c v1 09102017
Arrays in c v1 09102017
 
Cryptocurrency
Cryptocurrency Cryptocurrency
Cryptocurrency
 

Recently uploaded

Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
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
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
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
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
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.
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
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
 
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
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
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
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
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
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 

Recently uploaded (20)

Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
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
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
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
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
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
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
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
 
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
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
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...
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
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
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 

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