SlideShare una empresa de Scribd logo
1 de 11
INTRODUCTION
TYPES
Storage Class in C
Introduction
Storage class explain the behavior of the variable in
terms of scope and lifetime, it also determine the
initial of the variable.
Scope of the variable is the region over which the
variable is visible or valid.
Life time of the variable is the time during which
memory is associated with the variable.
Initial value is the value assigned to the variable
implicitly if no value is assigned to it by the
programmer.
There are four types of storage class available in C:
 Auto
 Extern
 Static
 Register
Auto
All local variables has this storage class.
Default value is the garbage value.
Scope of the variable is only between the blocks
where it is declared.
Lifetime is till the control remains within the block
or function where these variables are defined.
These variables are destroyed whenever block ends
or function jump occur.
To declare auto storage class auto keyword is used.
Example:
 auto int n;
Auto keyword is optional all the local variables by
default fall under this storage class.
Example:
 int n;
Extern
Scope is through out the program.
Lifetime is till the end of the program.
Initial value is 0.
Extern keyword is used to declare the variable of this
storage class.
 extern int x;
By default global variable has this storage class.
Static
It is special case of local variable.
These are defined inside the function or block.
Its scope is inside the block or the function where it
is defined.
Initial value is 0.
Its value is retained between different function calls.
Lifetime is same as the global variable i.e. through
out the program.
Keyword static is used to define this type of variable.
Register
Register variable behave in every way same as the
auto variable.
The only difference is that register variable are store
inside the computer register instead of the memory.
They are used when CPU has to access the variable
very frequently. Eg looping variable
They are defined by placing keyword register before
the datatype of variable. Example
 register int a=10;

Más contenido relacionado

La actualidad más candente

Templates in C++
Templates in C++Templates in C++
Templates in C++
Tech_MX
 

La actualidad más candente (20)

Storage class in C Language
Storage class in C LanguageStorage class in C Language
Storage class in C Language
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
 
Pure virtual function and abstract class
Pure virtual function and abstract classPure virtual function and abstract class
Pure virtual function and abstract class
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
 
C functions
C functionsC functions
C functions
 
STORAGE CLASSES
STORAGE CLASSESSTORAGE CLASSES
STORAGE CLASSES
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
 
Polymorphism In c++
Polymorphism In c++Polymorphism In c++
Polymorphism In c++
 
Constructor and Destructors in C++
Constructor and Destructors in C++Constructor and Destructors in C++
Constructor and Destructors in C++
 
Abstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core JavaAbstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core Java
 
07. Virtual Functions
07. Virtual Functions07. Virtual Functions
07. Virtual Functions
 
Functions in c
Functions in cFunctions in c
Functions in c
 
Storage classes in c language
Storage classes in c languageStorage classes in c language
Storage classes in c language
 
Storage class
Storage classStorage class
Storage class
 
Modules and packages in python
Modules and packages in pythonModules and packages in python
Modules and packages in python
 
Class and object in c++
Class and object in c++Class and object in c++
Class and object in c++
 
Storage classes
Storage classesStorage classes
Storage classes
 
Type conversion
Type conversionType conversion
Type conversion
 
16717 functions in C++
16717 functions in C++16717 functions in C++
16717 functions in C++
 
arrays and pointers
arrays and pointersarrays and pointers
arrays and pointers
 

Destacado

Array in c language
Array in c languageArray in c language
Array in c language
home
 
storage class
storage classstorage class
storage class
student
 
C and its errors
C and its errorsC and its errors
C and its errors
Junaid Raja
 

Destacado (18)

Array in c language
Array in c languageArray in c language
Array in c language
 
storage class
storage classstorage class
storage class
 
C and its errors
C and its errorsC and its errors
C and its errors
 
Pointers in C
Pointers in CPointers in C
Pointers in C
 
Design Pattern Libraries
Design Pattern LibrariesDesign Pattern Libraries
Design Pattern Libraries
 
Recursive Function
Recursive FunctionRecursive Function
Recursive Function
 
Union in C programming
Union in C programmingUnion in C programming
Union in C programming
 
Network Layer
Network LayerNetwork Layer
Network Layer
 
Memory
MemoryMemory
Memory
 
Loops in C
Loops in CLoops in C
Loops in C
 
Strings in C
Strings in CStrings in C
Strings in C
 
Loops c++
Loops c++Loops c++
Loops c++
 
File handling in C
File handling in CFile handling in C
File handling in C
 
Structure in C
Structure in CStructure in C
Structure in C
 
Arrays In C++
Arrays In C++Arrays In C++
Arrays In C++
 
Arrays
ArraysArrays
Arrays
 
Array in C
Array in CArray in C
Array in C
 
Type casting in c programming
Type casting in c programmingType casting in c programming
Type casting in c programming
 

Similar a Storage Class in C Progrmming

Latest C Interview Questions and Answers
Latest C Interview Questions and AnswersLatest C Interview Questions and Answers
Latest C Interview Questions and Answers
DaisyWatson5
 

Similar a Storage Class in C Progrmming (20)

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
 
Latest C Interview Questions and Answers
Latest C Interview Questions and AnswersLatest C Interview Questions and Answers
Latest C Interview Questions and Answers
 
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
 
Storage class
Storage classStorage class
Storage class
 
Storage classes
Storage classesStorage classes
Storage classes
 
Storage classes
Storage classesStorage classes
Storage classes
 
Storage Class Specifiers
Storage Class SpecifiersStorage Class Specifiers
Storage Class Specifiers
 
Chapter4-var.pdf
Chapter4-var.pdfChapter4-var.pdf
Chapter4-var.pdf
 
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
 
Advanced C Programming Notes
Advanced C Programming NotesAdvanced C Programming Notes
Advanced C Programming Notes
 
Notes of Important Programming Fundamental Questions
Notes of Important Programming Fundamental QuestionsNotes of Important Programming Fundamental Questions
Notes of Important Programming Fundamental Questions
 
STORAGE CLASS.pptx
STORAGE CLASS.pptxSTORAGE CLASS.pptx
STORAGE CLASS.pptx
 
Variables in java.pptx
Variables in java.pptxVariables in java.pptx
Variables in java.pptx
 
C programming session7
C programming  session7C programming  session7
C programming session7
 
C programming session7
C programming  session7C programming  session7
C programming session7
 

Más de Kamal Acharya

Más de Kamal Acharya (20)

Programming the basic computer
Programming the basic computerProgramming the basic computer
Programming the basic computer
 
Computer Arithmetic
Computer ArithmeticComputer Arithmetic
Computer Arithmetic
 
Introduction to Computer Security
Introduction to Computer SecurityIntroduction to Computer Security
Introduction to Computer Security
 
Session and Cookies
Session and CookiesSession and Cookies
Session and Cookies
 
Functions in php
Functions in phpFunctions in php
Functions in php
 
Web forms in php
Web forms in phpWeb forms in php
Web forms in php
 
Making decision and repeating in PHP
Making decision and repeating  in PHPMaking decision and repeating  in PHP
Making decision and repeating in PHP
 
Working with arrays in php
Working with arrays in phpWorking with arrays in php
Working with arrays in php
 
Text and Numbers (Data Types)in PHP
Text and Numbers (Data Types)in PHPText and Numbers (Data Types)in PHP
Text and Numbers (Data Types)in PHP
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Capacity Planning of Data Warehousing
Capacity Planning of Data WarehousingCapacity Planning of Data Warehousing
Capacity Planning of Data Warehousing
 
Data Warehousing
Data WarehousingData Warehousing
Data Warehousing
 
Search Engines
Search EnginesSearch Engines
Search Engines
 
Web Mining
Web MiningWeb Mining
Web Mining
 
Information Privacy and Data Mining
Information Privacy and Data MiningInformation Privacy and Data Mining
Information Privacy and Data Mining
 
Cluster Analysis
Cluster AnalysisCluster Analysis
Cluster Analysis
 
Association Analysis in Data Mining
Association Analysis in Data MiningAssociation Analysis in Data Mining
Association Analysis in Data Mining
 
Classification techniques in data mining
Classification techniques in data miningClassification techniques in data mining
Classification techniques in data mining
 
Data Preprocessing
Data PreprocessingData Preprocessing
Data Preprocessing
 
Introduction to Data Mining and Data Warehousing
Introduction to Data Mining and Data WarehousingIntroduction to Data Mining and Data Warehousing
Introduction to Data Mining and Data Warehousing
 

Último

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 

Último (20)

Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 

Storage Class in C Progrmming

  • 2. Introduction Storage class explain the behavior of the variable in terms of scope and lifetime, it also determine the initial of the variable. Scope of the variable is the region over which the variable is visible or valid. Life time of the variable is the time during which memory is associated with the variable. Initial value is the value assigned to the variable implicitly if no value is assigned to it by the programmer.
  • 3. There are four types of storage class available in C:  Auto  Extern  Static  Register
  • 4. Auto All local variables has this storage class. Default value is the garbage value. Scope of the variable is only between the blocks where it is declared. Lifetime is till the control remains within the block or function where these variables are defined. These variables are destroyed whenever block ends or function jump occur. To declare auto storage class auto keyword is used.
  • 5. Example:  auto int n; Auto keyword is optional all the local variables by default fall under this storage class. Example:  int n;
  • 6.
  • 7. Extern Scope is through out the program. Lifetime is till the end of the program. Initial value is 0. Extern keyword is used to declare the variable of this storage class.  extern int x; By default global variable has this storage class.
  • 8.
  • 9. Static It is special case of local variable. These are defined inside the function or block. Its scope is inside the block or the function where it is defined. Initial value is 0. Its value is retained between different function calls. Lifetime is same as the global variable i.e. through out the program. Keyword static is used to define this type of variable.
  • 10.
  • 11. Register Register variable behave in every way same as the auto variable. The only difference is that register variable are store inside the computer register instead of the memory. They are used when CPU has to access the variable very frequently. Eg looping variable They are defined by placing keyword register before the datatype of variable. Example  register int a=10;