SlideShare a Scribd company logo
BY,
A.Amalajoylet
Storage classes
STORAGE CLASSES
 The storage class determines the part of the
memory where the variables would be stored.
 The storage class also determines the initial
value of the variable.
 It is used to define the scope and lifetime of
variable.
 There are two storage locations in computer,
 1. CPU Registers
 2.Memory.
 A value stored in CPU register can always be
accessed faster than the one that is stored in
memory.
Four types
1.Automatic storage class.
2.Register storage class.
3.Static storage class.
4.External storage class.
Automatic
 Keywords : Auto
 Storage : Memory
 Default initial value : Garbage value
 Scope : Local/Block scope
 Life : Exists as long as
the control
remains in the
block
Example for Automatic
 void main()
{
auto x= 20 ;
{
auto x = 60 ;
printf("n x: %d",x);
}
printf("nx: %d",x);
}
 OUTPUT :
 x: 60
x: 20
 NOTE : Two variables are declared in different
blocks , so they are treated as different variables
Static
 Keywords : Static
 Storage : Memory
 Default initial value : 0
 Scope : Local to the block in
which
the variable is
defined.
 Life : Value of the variable
persists
between different
function calls.
Difference between auto and static
class
 /*auto class*/
#include<stdio.h>
void add();
int main()
{
add();
add();
add();
add();
return 0;
}
void add()
{
auto int i=1;
printf("n%d",i);
i=i+1;
 OUTPUT:-
1
1
1
1
 /*static class*/
#include<stdio.h>
void add();
int main()
{
add();
add();
add();
add();
return 0;
}
void add()
{
static int i=1;
printf("n%d",i);
i=i+1;
}
 OUTPUT:-
1
2
3
4

Previous program explanation
 If the storage class is static, then the statement
static int i = 1 is executed only once, irrespective
of how many times the same function is called.
 If the storage class is auto,then the statement
auto int i=1 is executed each time where it
increments and re-initialize the value of i= 1.
 The difference between them is
that static variable do not disappear when the
function is no longer active. There value persist. If
control comes back to the same function again ,
the static variables have the same values they
had last time around.
Register
 Keywords : Register.
 Storage : CPU register.
 Default initial value : Garbage value
 Scope : Local to the block in
which
the variable is
defined.
 Life : Value of the variable
persists
till the control
remains within
the block in which
Why we need Register Variable
?
 Whenever we declare any variable inside C Program
then memory will be randomly allocated at particular
memory location.
 We have to keep track of that memory location. We
need to access value at that memory location using
ampersand operator/Address Operator i.e (&).
 If we store same variable in the register memory then
we can access that memory location directly without
using the Address operator.
 Register variable will be accessed faster than the
normal variable thus increasing the operation and
program execution. Generally we use register variable
as Counter.
 Note : It is not applicable for arrays, structures or
pointers.
External
 Keywords : Extern.
 Storage : Memory.
 Default initial value : 0
 Scope : Global
 Life : Exists as long as
variable is
running
Retains value within
the function
Example for Extern
 int num = 75 ;
void display();
void main()
{
extern int num ;
printf("nNum : %d",num);
display();
}
void display()
{
extern int num ;
printf("nNum : %d",num);
}
 OUTPUT:
 Num : 75
Num : 75
Extern contd…
Note :Declaration within the function indicates
that the function uses external variable
Functions belonging to same source code ,
does not require declaration (no need to write
extern)
If variable is defined outside the source code ,
then declaration using extern keyword is
required
 THANK YOU

More Related Content

What's hot

Inline function in C++
Inline function in C++Inline function in C++
Inline function in C++
Jenish Patel
 
Inline function
Inline functionInline function
Inline function
Tech_MX
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
Nilesh Dalvi
 
Packages in java
Packages in javaPackages in java
Packages in java
Elizabeth alexander
 
Presentation on C Switch Case Statements
Presentation on C Switch Case StatementsPresentation on C Switch Case Statements
Presentation on C Switch Case Statements
Dipesh Pandey
 
Dynamic memory allocation in c
Dynamic memory allocation in cDynamic memory allocation in c
Dynamic memory allocation in c
lavanya marichamy
 
Union in C programming
Union in C programmingUnion in C programming
Union in C programming
Kamal Acharya
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
janani thirupathi
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of Constructors
Dhrumil Panchal
 
Memory allocation in c
Memory allocation in cMemory allocation in c
Memory allocation in c
Prabhu Govind
 
Object oriented programming c++
Object oriented programming c++Object oriented programming c++
Object oriented programming c++
Ankur Pandey
 
Embedded C - Lecture 2
Embedded C - Lecture 2Embedded C - Lecture 2
Embedded C - Lecture 2
Mohamed Abdallah
 
Break and continue
Break and continueBreak and continue
Break and continue
Frijo Francis
 
Union in c language
Union  in c languageUnion  in c language
Union in c language
tanmaymodi4
 
Embedded C - Lecture 4
Embedded C - Lecture 4Embedded C - Lecture 4
Embedded C - Lecture 4
Mohamed Abdallah
 
Functions in C
Functions in CFunctions in C
Functions in C
Kamal Acharya
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programming
TejaswiB4
 
Storage classes
Storage classesStorage classes
Storage classes
Leela Koneru
 
Data members and member functions
Data members and member functionsData members and member functions
Data members and member functions
Marlom46
 
Dynamic Memory Allocation in C
Dynamic Memory Allocation in CDynamic Memory Allocation in C
Dynamic Memory Allocation in C
Vijayananda Ratnam Ch
 

What's hot (20)

Inline function in C++
Inline function in C++Inline function in C++
Inline function in C++
 
Inline function
Inline functionInline function
Inline function
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
 
Packages in java
Packages in javaPackages in java
Packages in java
 
Presentation on C Switch Case Statements
Presentation on C Switch Case StatementsPresentation on C Switch Case Statements
Presentation on C Switch Case Statements
 
Dynamic memory allocation in c
Dynamic memory allocation in cDynamic memory allocation in c
Dynamic memory allocation in c
 
Union in C programming
Union in C programmingUnion in C programming
Union in C programming
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of Constructors
 
Memory allocation in c
Memory allocation in cMemory allocation in c
Memory allocation in c
 
Object oriented programming c++
Object oriented programming c++Object oriented programming c++
Object oriented programming c++
 
Embedded C - Lecture 2
Embedded C - Lecture 2Embedded C - Lecture 2
Embedded C - Lecture 2
 
Break and continue
Break and continueBreak and continue
Break and continue
 
Union in c language
Union  in c languageUnion  in c language
Union in c language
 
Embedded C - Lecture 4
Embedded C - Lecture 4Embedded C - Lecture 4
Embedded C - Lecture 4
 
Functions in C
Functions in CFunctions in C
Functions in C
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programming
 
Storage classes
Storage classesStorage classes
Storage classes
 
Data members and member functions
Data members and member functionsData members and member functions
Data members and member functions
 
Dynamic Memory Allocation in C
Dynamic Memory Allocation in CDynamic Memory Allocation in C
Dynamic Memory Allocation in C
 

Similar to Storage class

Storage class
Storage classStorage class
Storage class
Kalaikumar Thangapandi
 
Storage classes
Storage classesStorage classes
Storage classes
Leela Koneru
 
Storage classes in c language
Storage classes in c languageStorage classes in c language
Storage classes in c language
Tanmay Modi
 
Storage classes
Storage classesStorage classes
Storage classes
UTTAM VERMA
 
STORAGE CLASSES
STORAGE CLASSESSTORAGE CLASSES
STORAGE CLASSES
sathish sak
 
Storage Class Specifiers in C++
Storage Class Specifiers in C++Storage Class Specifiers in C++
Storage Class Specifiers in C++
Reddhi Basu
 
Storage classes
Storage classesStorage classes
Storage classes
Praveen M Jigajinni
 
Storage classes
Storage classesStorage classes
Storage classes
priyanka jain
 
What is storage class
What is storage classWhat is storage class
What is storage class
Isha Aggarwal
 
Latest C Interview Questions and Answers
Latest C Interview Questions and AnswersLatest C Interview Questions and Answers
Latest C Interview Questions and Answers
DaisyWatson5
 
Storage classes
Storage classesStorage classes
Storage classes
Puneet Rajput
 
Advanced C Programming Notes
Advanced C Programming NotesAdvanced C Programming Notes
Advanced C Programming Notes
Leslie Schulte
 
Storage class
Storage classStorage class
Storage class
Kathmandu University
 
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
Storage Class SpecifiersStorage Class Specifiers
Storage Class Specifiers
Reddhi Basu
 
memory
memorymemory
memory
teach4uin
 
Storage_classes_and_Scope_rules.pptx
Storage_classes_and_Scope_rules.pptxStorage_classes_and_Scope_rules.pptx
Storage_classes_and_Scope_rules.pptx
CheriviralaNikhil
 
Terms and Definitions.pdf
Terms and Definitions.pdfTerms and Definitions.pdf
Terms and Definitions.pdf
SheikhAbrarAhmad
 
Storage Classes and Functions
Storage Classes and FunctionsStorage Classes and Functions
Storage Classes and Functions
Jake Bond
 
Storage classes
Storage classesStorage classes
Storage classes
Shanmughaneethi Velu
 

Similar to Storage class (20)

Storage class
Storage classStorage class
Storage class
 
Storage classes
Storage classesStorage classes
Storage classes
 
Storage classes in c language
Storage classes in c languageStorage classes in c language
Storage classes in c language
 
Storage classes
Storage classesStorage classes
Storage classes
 
STORAGE CLASSES
STORAGE CLASSESSTORAGE CLASSES
STORAGE CLASSES
 
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
 
Storage classes
Storage classesStorage classes
Storage classes
 
What is storage class
What is storage classWhat is storage class
What is storage class
 
Latest C Interview Questions and Answers
Latest C Interview Questions and AnswersLatest C Interview Questions and Answers
Latest C Interview Questions and Answers
 
Storage classes
Storage classesStorage classes
Storage classes
 
Advanced C Programming Notes
Advanced C Programming NotesAdvanced C Programming Notes
Advanced C Programming Notes
 
Storage class
Storage classStorage class
Storage class
 
Storage classess of C progamming
Storage classess of C progamming Storage classess of C progamming
Storage classess of C progamming
 
Storage Class Specifiers
Storage Class SpecifiersStorage Class Specifiers
Storage Class Specifiers
 
memory
memorymemory
memory
 
Storage_classes_and_Scope_rules.pptx
Storage_classes_and_Scope_rules.pptxStorage_classes_and_Scope_rules.pptx
Storage_classes_and_Scope_rules.pptx
 
Terms and Definitions.pdf
Terms and Definitions.pdfTerms and Definitions.pdf
Terms and Definitions.pdf
 
Storage Classes and Functions
Storage Classes and FunctionsStorage Classes and Functions
Storage Classes and Functions
 
Storage classes
Storage classesStorage classes
Storage classes
 

Recently uploaded

Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
Madan Karki
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
drwaing
 
sieving analysis and results interpretation
sieving analysis and results interpretationsieving analysis and results interpretation
sieving analysis and results interpretation
ssuser36d3051
 
2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt
PuktoonEngr
 
International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...
gerogepatton
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
JamalHussainArman
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
NidhalKahouli2
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
Divyam548318
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
Low power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniquesLow power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniques
nooriasukmaningtyas
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
jpsjournal1
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
ClaraZara1
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
SyedAbiiAzazi1
 
Heat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation pptHeat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation ppt
mamunhossenbd75
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
gestioneergodomus
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
University of Maribor
 
Wearable antenna for antenna applications
Wearable antenna for antenna applicationsWearable antenna for antenna applications
Wearable antenna for antenna applications
Madhumitha Jayaram
 

Recently uploaded (20)

Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
 
sieving analysis and results interpretation
sieving analysis and results interpretationsieving analysis and results interpretation
sieving analysis and results interpretation
 
2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt
 
International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
Low power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniquesLow power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniques
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
 
Heat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation pptHeat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation ppt
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
 
Wearable antenna for antenna applications
Wearable antenna for antenna applicationsWearable antenna for antenna applications
Wearable antenna for antenna applications
 

Storage class

  • 2. STORAGE CLASSES  The storage class determines the part of the memory where the variables would be stored.  The storage class also determines the initial value of the variable.  It is used to define the scope and lifetime of variable.  There are two storage locations in computer,  1. CPU Registers  2.Memory.  A value stored in CPU register can always be accessed faster than the one that is stored in memory.
  • 3. Four types 1.Automatic storage class. 2.Register storage class. 3.Static storage class. 4.External storage class.
  • 4. Automatic  Keywords : Auto  Storage : Memory  Default initial value : Garbage value  Scope : Local/Block scope  Life : Exists as long as the control remains in the block
  • 5. Example for Automatic  void main() { auto x= 20 ; { auto x = 60 ; printf("n x: %d",x); } printf("nx: %d",x); }  OUTPUT :  x: 60 x: 20  NOTE : Two variables are declared in different blocks , so they are treated as different variables
  • 6. Static  Keywords : Static  Storage : Memory  Default initial value : 0  Scope : Local to the block in which the variable is defined.  Life : Value of the variable persists between different function calls.
  • 7. Difference between auto and static class  /*auto class*/ #include<stdio.h> void add(); int main() { add(); add(); add(); add(); return 0; } void add() { auto int i=1; printf("n%d",i); i=i+1;  OUTPUT:- 1 1 1 1  /*static class*/ #include<stdio.h> void add(); int main() { add(); add(); add(); add(); return 0; } void add() { static int i=1; printf("n%d",i); i=i+1; }  OUTPUT:- 1 2 3 4 
  • 8. Previous program explanation  If the storage class is static, then the statement static int i = 1 is executed only once, irrespective of how many times the same function is called.  If the storage class is auto,then the statement auto int i=1 is executed each time where it increments and re-initialize the value of i= 1.  The difference between them is that static variable do not disappear when the function is no longer active. There value persist. If control comes back to the same function again , the static variables have the same values they had last time around.
  • 9. Register  Keywords : Register.  Storage : CPU register.  Default initial value : Garbage value  Scope : Local to the block in which the variable is defined.  Life : Value of the variable persists till the control remains within the block in which
  • 10. Why we need Register Variable ?  Whenever we declare any variable inside C Program then memory will be randomly allocated at particular memory location.  We have to keep track of that memory location. We need to access value at that memory location using ampersand operator/Address Operator i.e (&).  If we store same variable in the register memory then we can access that memory location directly without using the Address operator.  Register variable will be accessed faster than the normal variable thus increasing the operation and program execution. Generally we use register variable as Counter.  Note : It is not applicable for arrays, structures or pointers.
  • 11. External  Keywords : Extern.  Storage : Memory.  Default initial value : 0  Scope : Global  Life : Exists as long as variable is running Retains value within the function
  • 12. Example for Extern  int num = 75 ; void display(); void main() { extern int num ; printf("nNum : %d",num); display(); } void display() { extern int num ; printf("nNum : %d",num); }  OUTPUT:  Num : 75 Num : 75
  • 13. Extern contd… Note :Declaration within the function indicates that the function uses external variable Functions belonging to same source code , does not require declaration (no need to write extern) If variable is defined outside the source code , then declaration using extern keyword is required