SlideShare une entreprise Scribd logo
1  sur  15
NITESH KUMAR PANDEY
STORAGE CLASS

 The storage class determines the part of the memory
  where the variable would be stored.
 The storage class also determines the initial value of
  the variable.
 and it used to define the scope and lifetime of
  variable.
 There are two storage location in computer :
   CPU Registers and Memory
CPU REGISTER AND MEMORY

 A value stored in a CPU register can always be
 accessed faster then the one that is stored in
 memory.
TYPES OF STORAGE CLASSES

There are four types of storage classes in C:
i.   Automatic storage class
ii.   Register storage class
iii.  Static storage class
iv.   External storage class
Automatic Storage Class

 Keywords                : auto.
 Storage                  : memory.
 Default initial value     : garbage value.
 Scope                     : local to the block in
                                which the variable is
                                defined.
 Life                     : till the control remains
                                within the block in which
                                the variable is defined.
Example of Automatic Storage Class

#include<stdio.h>
#include<conio.h>
void main()
{
auto int i=1;
{
auto int i=2;
{
auto int i=3;
printf(“n%d”,i);
}
printf(“%d”,i);
}
printf(“%d”,i);
getch();
}

Output:
3 2 1
Register Storage Class

 Keywords                : register.
 Storage                  : CPU Register.
 Default initial value   : garbage value.
 Scope                   : local to the block in
                             which the variable is
                              defined.
 Life                     : till the control remains
                                within the block in which
                                the variable is defined.
Example of Register Storage Class

#include<stdio.h>
#include<conio.h>
void main()
{
register int i;
for(i=1;i<=10;i++)
printf(“ %d",i);
getch();
}
Output:
1 2 3 4 5 6 7 8 9 10
Register Storage Class

 If the microprocessor has 16-bit registers then they
  cannot hold a float value or a double value which
  requires 4bytes(32-bit) and 8 bytes(64-bit)
 If you want to use the register storage class(16-bit
  microprocessor) with float and double variable then
  you won‟t get any error messages. Your compiler
  would treat the variables as auto storage class.
Static Storage Class

 Keywords                : static.
 Storage                  : memory.
 Default initial value     : zero.
 Scope                     : local to the block in
                              which the variable is
                              defined.
 Life                     : value of the variable
                               persists between different
                               function calls.
Dif. b/w auto and static storage class

Automatic                   Static

#include<stdio.h>           #include<stdio.h>
#include<conio.h>           #include<conio.h>
increment();                increment();
void main()                 void main()
{                           {
increment();                increment();
increment();                increment();
increment();                increment();
}                           }
increment()                 increment()
{                           {
auto int i=1;               static int i=1;
printf("%dt",i);           printf("%dt",i);
i++;                        i++;
getch();                    getch();
}                           }
Output:                     Output:
1 1           1             1      2       3
External Storage Class

 Keywords                 : extern.
 Storage                 : memory.
 Default initial value   : zero.
 Scope                   : global.
 Life                     : as long as the program‟s
                             execution doesn‟t come
                              to an end.
• The  different b/w two programs 1st auto and 2nd
static storage class for variable „i‟ the scope of
auto and static both use local to the block in witch
the variable is declared.
• Those program consists two functions main() and
increment().
• The increment() function called from main()
function for three times.
• Each time increment the value of „i‟ and print.
• when variable „i‟ is auto each time increment and
re-initialized to 1.
Example of External Storage Class
#include<stdio.h>
#include<conio.h>
int i =1;
increment();
void main()
{
printf("%dt",i);
increment();
increment();
getch();
}
increment()
{
i++;
printf("%dt",i);
}
Output:
1 2       3
Storage class in C Language

Contenu connexe

Tendances

Tendances (20)

Input output statement in C
Input output statement in CInput output statement in C
Input output statement in C
 
Storage class
Storage classStorage class
Storage class
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
 
While , For , Do-While Loop
While , For , Do-While LoopWhile , For , Do-While Loop
While , For , Do-While Loop
 
Array in c
Array in cArray in c
Array in c
 
File handling in c
File handling in cFile handling in c
File handling in c
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
 
Call by value
Call by valueCall by value
Call by value
 
Data types in C
Data types in CData types in C
Data types in C
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
 
Type conversion
Type conversionType conversion
Type conversion
 
Looping statements in C
Looping statements in CLooping statements in C
Looping statements in C
 
07. Virtual Functions
07. Virtual Functions07. Virtual Functions
07. Virtual Functions
 
Storage classes in C
Storage classes in CStorage classes in C
Storage classes in C
 
Type casting in c programming
Type casting in c programmingType casting in c programming
Type casting in c programming
 
File handling in c
File handling in cFile handling in c
File handling in c
 
Functions in C
Functions in CFunctions in C
Functions in C
 
Loops in C Programming Language
Loops in C Programming LanguageLoops in C Programming Language
Loops in C Programming Language
 
Union in C programming
Union in C programmingUnion in C programming
Union in C programming
 
Loops in C
Loops in CLoops in C
Loops in C
 

En vedette (20)

11 lec 11 storage class
11 lec 11 storage class11 lec 11 storage class
11 lec 11 storage class
 
Storage Classes and Functions
Storage Classes and FunctionsStorage Classes and Functions
Storage Classes and Functions
 
Storage class in c
Storage class in cStorage class in c
Storage class in c
 
Storage Class in C Progrmming
Storage Class in C Progrmming Storage Class in C Progrmming
Storage Class in C Progrmming
 
Storage class
Storage classStorage class
Storage class
 
Variables, Data Types, Operator & Expression in c in detail
Variables, Data Types, Operator & Expression in c in detailVariables, Data Types, Operator & Expression in c in detail
Variables, Data Types, Operator & Expression in c in detail
 
Memory
MemoryMemory
Memory
 
Jdbc
JdbcJdbc
Jdbc
 
Enumerated data types in C
Enumerated data types in CEnumerated data types in C
Enumerated data types in C
 
Arrays
ArraysArrays
Arrays
 
Overview of c language
Overview of c languageOverview of c language
Overview of c language
 
Array in c language
Array in c languageArray in c language
Array in c language
 
Control statements
Control statementsControl statements
Control statements
 
Solid waste management ppt
Solid waste management pptSolid waste management ppt
Solid waste management ppt
 
Scope of variables
Scope of variablesScope of variables
Scope of variables
 
Storage classes
Storage classesStorage classes
Storage classes
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
 
Scope of variables
Scope of variablesScope of variables
Scope of variables
 
Multi Media Technology
Multi Media TechnologyMulti Media Technology
Multi Media Technology
 
Operatingsystems lecture2
Operatingsystems lecture2Operatingsystems lecture2
Operatingsystems lecture2
 

Similaire à Storage class in C Language

from java to c
from java to cfrom java to c
from java to cVõ Hòa
 
What is storage class
What is storage classWhat is storage class
What is storage classIsha Aggarwal
 
C Storage Classes VSN
C Storage Classes VSNC Storage Classes VSN
C Storage Classes VSNNITTTR
 
Storage classes in C
Storage classes in C Storage classes in C
Storage classes in C Self employed
 
C Programming Storage classes, Recursion
C Programming Storage classes, RecursionC Programming Storage classes, Recursion
C Programming Storage classes, RecursionSreedhar Chowdam
 
Getting Started Cpp
Getting Started CppGetting Started Cpp
Getting Started CppLong Cao
 
Storage_classes_and_Scope_rules.pptx
Storage_classes_and_Scope_rules.pptxStorage_classes_and_Scope_rules.pptx
Storage_classes_and_Scope_rules.pptxCheriviralaNikhil
 
Data structure week 1
Data structure week 1Data structure week 1
Data structure week 1karmuhtam
 
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...Muhammad Ulhaque
 
storage class
storage classstorage class
storage classstudent
 

Similaire à Storage class in C Language (20)

Storage class
Storage classStorage class
Storage class
 
Storage classes
Storage classesStorage classes
Storage classes
 
Storage class
Storage classStorage class
Storage class
 
Storage class
Storage classStorage class
Storage class
 
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 classes
Storage classesStorage classes
Storage classes
 
C Storage Classes VSN
C Storage Classes VSNC Storage Classes VSN
C Storage Classes VSN
 
Lecture 13 - Storage Classes
Lecture 13 - Storage ClassesLecture 13 - Storage Classes
Lecture 13 - Storage Classes
 
Storage classes in C
Storage classes in C Storage classes in C
Storage classes in C
 
C Programming Storage classes, Recursion
C Programming Storage classes, RecursionC Programming Storage classes, Recursion
C Programming Storage classes, Recursion
 
Getting Started Cpp
Getting Started CppGetting Started Cpp
Getting Started Cpp
 
Storage_classes_and_Scope_rules.pptx
Storage_classes_and_Scope_rules.pptxStorage_classes_and_Scope_rules.pptx
Storage_classes_and_Scope_rules.pptx
 
Data structure week 1
Data structure week 1Data structure week 1
Data structure week 1
 
Storage classes
Storage classesStorage classes
Storage classes
 
visiblity and scope.pptx
visiblity and scope.pptxvisiblity and scope.pptx
visiblity and scope.pptx
 
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...
 
storage class
storage classstorage class
storage class
 
Unit iii
Unit iiiUnit iii
Unit iii
 
C++ theory
C++ theoryC++ theory
C++ theory
 

Dernier

diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....Ritu480198
 
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...Krashi Coaching
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptxPoojaSen20
 
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING IIII BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING IIagpharmacy11
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhleson0603
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...Nguyen Thanh Tu Collection
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽中 央社
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptxPoojaSen20
 
How to Manage Closest Location in Odoo 17 Inventory
How to Manage Closest Location in Odoo 17 InventoryHow to Manage Closest Location in Odoo 17 Inventory
How to Manage Closest Location in Odoo 17 InventoryCeline George
 
Chapter 7 Pharmacosy Traditional System of Medicine & Ayurvedic Preparations ...
Chapter 7 Pharmacosy Traditional System of Medicine & Ayurvedic Preparations ...Chapter 7 Pharmacosy Traditional System of Medicine & Ayurvedic Preparations ...
Chapter 7 Pharmacosy Traditional System of Medicine & Ayurvedic Preparations ...Sumit Tiwari
 
Poster_density_driven_with_fracture_MLMC.pdf
Poster_density_driven_with_fracture_MLMC.pdfPoster_density_driven_with_fracture_MLMC.pdf
Poster_density_driven_with_fracture_MLMC.pdfAlexander Litvinenko
 
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...Denish Jangid
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptxVishal Singh
 
Benefits and Challenges of OER by Shweta Babel.pptx
Benefits and Challenges of OER by Shweta Babel.pptxBenefits and Challenges of OER by Shweta Babel.pptx
Benefits and Challenges of OER by Shweta Babel.pptxsbabel
 
The Ball Poem- John Berryman_20240518_001617_0000.pptx
The Ball Poem- John Berryman_20240518_001617_0000.pptxThe Ball Poem- John Berryman_20240518_001617_0000.pptx
The Ball Poem- John Berryman_20240518_001617_0000.pptxNehaChandwani11
 
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45MysoreMuleSoftMeetup
 
Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Mohamed Rizk Khodair
 
Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024CapitolTechU
 

Dernier (20)

Word Stress rules esl .pptx
Word Stress rules esl               .pptxWord Stress rules esl               .pptx
Word Stress rules esl .pptx
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING IIII BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
How to Manage Closest Location in Odoo 17 Inventory
How to Manage Closest Location in Odoo 17 InventoryHow to Manage Closest Location in Odoo 17 Inventory
How to Manage Closest Location in Odoo 17 Inventory
 
Chapter 7 Pharmacosy Traditional System of Medicine & Ayurvedic Preparations ...
Chapter 7 Pharmacosy Traditional System of Medicine & Ayurvedic Preparations ...Chapter 7 Pharmacosy Traditional System of Medicine & Ayurvedic Preparations ...
Chapter 7 Pharmacosy Traditional System of Medicine & Ayurvedic Preparations ...
 
IPL Online Quiz by Pragya; Question Set.
IPL Online Quiz by Pragya; Question Set.IPL Online Quiz by Pragya; Question Set.
IPL Online Quiz by Pragya; Question Set.
 
Poster_density_driven_with_fracture_MLMC.pdf
Poster_density_driven_with_fracture_MLMC.pdfPoster_density_driven_with_fracture_MLMC.pdf
Poster_density_driven_with_fracture_MLMC.pdf
 
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptx
 
Benefits and Challenges of OER by Shweta Babel.pptx
Benefits and Challenges of OER by Shweta Babel.pptxBenefits and Challenges of OER by Shweta Babel.pptx
Benefits and Challenges of OER by Shweta Babel.pptx
 
The Ball Poem- John Berryman_20240518_001617_0000.pptx
The Ball Poem- John Berryman_20240518_001617_0000.pptxThe Ball Poem- John Berryman_20240518_001617_0000.pptx
The Ball Poem- John Berryman_20240518_001617_0000.pptx
 
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
 
Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).
 
Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024
 

Storage class in C Language

  • 2. STORAGE CLASS  The storage class determines the part of the memory where the variable would be stored.  The storage class also determines the initial value of the variable.  and it used to define the scope and lifetime of variable.  There are two storage location in computer : CPU Registers and Memory
  • 3. CPU REGISTER AND MEMORY  A value stored in a CPU register can always be accessed faster then the one that is stored in memory.
  • 4. TYPES OF STORAGE CLASSES There are four types of storage classes in C: i. Automatic storage class ii. Register storage class iii. Static storage class iv. External storage class
  • 5. Automatic Storage Class  Keywords : auto.  Storage : memory.  Default initial value : garbage value.  Scope : local to the block in which the variable is defined.  Life : till the control remains within the block in which the variable is defined.
  • 6. Example of Automatic Storage Class #include<stdio.h> #include<conio.h> void main() { auto int i=1; { auto int i=2; { auto int i=3; printf(“n%d”,i); } printf(“%d”,i); } printf(“%d”,i); getch(); } Output: 3 2 1
  • 7. Register Storage Class  Keywords : register.  Storage : CPU Register.  Default initial value : garbage value.  Scope : local to the block in which the variable is defined.  Life : till the control remains within the block in which the variable is defined.
  • 8. Example of Register Storage Class #include<stdio.h> #include<conio.h> void main() { register int i; for(i=1;i<=10;i++) printf(“ %d",i); getch(); } Output: 1 2 3 4 5 6 7 8 9 10
  • 9. Register Storage Class  If the microprocessor has 16-bit registers then they cannot hold a float value or a double value which requires 4bytes(32-bit) and 8 bytes(64-bit)  If you want to use the register storage class(16-bit microprocessor) with float and double variable then you won‟t get any error messages. Your compiler would treat the variables as auto storage class.
  • 10. Static Storage Class  Keywords : static.  Storage : memory.  Default initial value : zero.  Scope : local to the block in which the variable is defined.  Life : value of the variable persists between different function calls.
  • 11. Dif. b/w auto and static storage class Automatic Static #include<stdio.h> #include<stdio.h> #include<conio.h> #include<conio.h> increment(); increment(); void main() void main() { { increment(); increment(); increment(); increment(); increment(); increment(); } } increment() increment() { { auto int i=1; static int i=1; printf("%dt",i); printf("%dt",i); i++; i++; getch(); getch(); } } Output: Output: 1 1 1 1 2 3
  • 12. External Storage Class  Keywords : extern.  Storage : memory.  Default initial value : zero.  Scope : global.  Life : as long as the program‟s execution doesn‟t come to an end.
  • 13. • The different b/w two programs 1st auto and 2nd static storage class for variable „i‟ the scope of auto and static both use local to the block in witch the variable is declared. • Those program consists two functions main() and increment(). • The increment() function called from main() function for three times. • Each time increment the value of „i‟ and print. • when variable „i‟ is auto each time increment and re-initialized to 1.
  • 14. Example of External Storage Class #include<stdio.h> #include<conio.h> int i =1; increment(); void main() { printf("%dt",i); increment(); increment(); getch(); } increment() { i++; printf("%dt",i); } Output: 1 2 3