SlideShare une entreprise Scribd logo
1  sur  15
Storage
Classes( Characteristics of Variable )
Prepared By
Vishnu Sharma(MCA)
www.examengine.info
Prepared By Vishnu Sharma(MCA) for www.examengine.info
Meaning of Storage Class
Each variable declared in C contains not only its
data type but also it has a storage class specified
with it.
If user do not specify the storage class of a
variable , the compiler will assume its storage
class as default i.e. automatic .
Prepared By Vishnu Sharma(MCA) for www.examengine.info
Purpose of Storage Class
The storage class of a variable tells us about :-
I. Storage Place of Variable i.e. Memory or CPU Registers
II. Initial value of Variable
III. Scope of Variable
IV. Lifetime of Variable i.e. how long variable exists.
Prepared By Vishnu Sharma(MCA) for www.examengine.info
How Storage Class Declared ????
auto int a ,b ;
Storage
Class
Data Type Variable
Prepared By Vishnu Sharma(MCA) for www.examengine.info
Four Type of Storage Class in C
Language :-
 Automatic Storage Class ( Local Variables )
 Register Storage Class
 Static Storage Class
 External Storage Class
Prepared By Vishnu Sharma(MCA) for www.examengine.info
Automatic Storage Class
Characteristi
cs
Meaning
Storage Memory
Initial Value Garbage Value i.e. An Unpredictable Value.
Scope or
Visibility
Local or Visible in the Block in which it is declared.
Life Time It retains its value till it is in the block in which it is
declared.
This is the default storage class for all the variable . It always
reinitialize the value of variable .It is declared as : -
auto int a ;
Prepared By Vishnu Sharma(MCA) for www.examengine.info
Void main ( )
{
auto int i , j = 5 ;
int k ,m =10 ; // By Default Automatic
Storage Class
printf ( “ value of i = % d n value of j = %
d “ , i , j ) ;
printf ( “ value of k = % d n value of m = %
d “ , i , j ) ;
}
Value of i = 2009
Value of j = 5
Value of k = 1005
Value of m = 10
Garbage Value
Variable Value
Use of Automatic Storage Class
Prepared By Vishnu Sharma(MCA) for www.examengine.info
#include<stdio.h>
int main()
{
auto int i=1;
{
 auto int i=2;
 {
 auto int i=3;
 printf(“%d”,i);
 }
 printf(“%d”,i);
 } printf(“%d”,i);
 return 0;Prepared By Vishnu Sharma(MCA) for www.examengine.info
Use of Automatic Storage Class
void ck ( ) ;
void main( )
{
clrscr ( ) ;
ck ( ) ;
ck ( ) ;
ck ( ) ;
getch( ) ;
}
void ck ( )
{
int i = 0 ;
printf ( “nn Value of I ..%d”,i ) ;
i + + ;
}
Output
0
0
0
Prepared By Vishnu Sharma(MCA) for www.examengine.info
Register Storage Class
Characteristic
s
Meaning
Storage C P U Registers
Initial Value Garbage Value
Scope or
Visibility
Local to the Block in which it is declared
Life Time It retains its value till the control remains in the block
In this storage class , variable is stored in C P U Registers , just for the
sake of increase the execution speed of some variable of program. It is
declares as :-
register int a ;
Prepared By Vishnu Sharma(MCA) for www.examengine.info
Void main ( )
{
register int i ;
for ( i = 1 ; i < = 100 ; i + + )
{
printf ( “ n % d “ , i ) ;
}
}
Use of Register Storage Class
Prepared By Vishnu Sharma(MCA) for www.examengine.info
Static Storage Class
This storage class is used when a user want that a variable should retain its
value even after the execution of the function in which it is declared, then
this storage class is used . It is declared as follow :-
static int a ;
Characteristic
s
Meaning
Storage Memory
Initial Value Zero ( 0 )
Scope or
Visibility
Local to the block in which it is declared
Life Time It retains its value between the different functionPrepared By Vishnu Sharma(MCA) for www.examengine.info
Use of Static Storage Class
void ck ( ) ;
void main( )
{
clrscr ( ) ;
ck ( ) ;
ck ( ) ;
ck ( ) ;
getch( ) ;
}
void ck ( )
{
static int i = 0 ;
printf ( “nn Value of I ..%d”,i ) ;
i + + ;
}
Output
0
1
2
Prepared By Vishnu Sharma(MCA) for www.examengine.info
External Storage Class
Characteristic
s
Meaning
Storage Memory
Initial Value Zero ( 0 )
Scope or
Visibility
Global ( Visible in all the Program )
Life Time It retains its value through out the whole program
External variables are declared outside all functions i.e, at the beginning of
the program. Global variables should be available to all the functions with
the help of extern specifier. It is declared as follow : -
extern int a ;
Prepared By Vishnu Sharma(MCA) for www.examengine.info
Use of External Storage Class
extern int a = 10 ;
void ck ( ) ;
void main( )
{
int a = 5 ;
printf ( “ %d “ , a) ;
ck ( ) ;
getch ( ) ;
}
void ck ( )
{
a = a + 10 ;
printf ( “nn Value of a ..%d”,a ) ;
}
Output
5
20
Prepared By Vishnu Sharma(MCA) for www.examengine.info

Contenu connexe

Tendances

String in c programming
String in c programmingString in c programming
String in c programmingDevan Thakur
 
String functions and operations
String functions and operations String functions and operations
String functions and operations Mudasir Syed
 
Basic Data Types in C++
Basic Data Types in C++ Basic Data Types in C++
Basic Data Types in C++ Hridoy Bepari
 
Overview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya JyothiOverview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya JyothiSowmya Jyothi
 
C language industrial training report
C language industrial training reportC language industrial training report
C language industrial training reportRaushan Pandey
 
Quest 1 define a class batsman with the following specifications
Quest  1 define a class batsman with the following specificationsQuest  1 define a class batsman with the following specifications
Quest 1 define a class batsman with the following specificationsrajkumari873
 
Strings in c
Strings in cStrings in c
Strings in cvampugani
 
USE OF PRINT IN PYTHON PART 2
USE OF PRINT IN PYTHON PART 2USE OF PRINT IN PYTHON PART 2
USE OF PRINT IN PYTHON PART 2vikram mahendra
 
Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)Saket Pathak
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++rprajat007
 

Tendances (20)

Graphics in C++
Graphics in C++Graphics in C++
Graphics in C++
 
String in c programming
String in c programmingString in c programming
String in c programming
 
String functions and operations
String functions and operations String functions and operations
String functions and operations
 
Printf and scanf
Printf and scanfPrintf and scanf
Printf and scanf
 
C programming notes
C programming notesC programming notes
C programming notes
 
Basic Data Types in C++
Basic Data Types in C++ Basic Data Types in C++
Basic Data Types in C++
 
Overview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya JyothiOverview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya Jyothi
 
Functions in c
Functions in cFunctions in c
Functions in c
 
C language industrial training report
C language industrial training reportC language industrial training report
C language industrial training report
 
Quest 1 define a class batsman with the following specifications
Quest  1 define a class batsman with the following specificationsQuest  1 define a class batsman with the following specifications
Quest 1 define a class batsman with the following specifications
 
Strings in c
Strings in cStrings in c
Strings in c
 
USE OF PRINT IN PYTHON PART 2
USE OF PRINT IN PYTHON PART 2USE OF PRINT IN PYTHON PART 2
USE OF PRINT IN PYTHON PART 2
 
C fundamental
C fundamentalC fundamental
C fundamental
 
Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
Strings in java
Strings in javaStrings in java
Strings in java
 
functions of C++
functions of C++functions of C++
functions of C++
 
Function in c
Function in cFunction in c
Function in c
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
 
Access modifiers in java
Access modifiers in javaAccess modifiers in java
Access modifiers in java
 

Similaire à storage class

Java ppt Gandhi Ravi (gandhiri@gmail.com)
Java ppt  Gandhi Ravi  (gandhiri@gmail.com)Java ppt  Gandhi Ravi  (gandhiri@gmail.com)
Java ppt Gandhi Ravi (gandhiri@gmail.com)Gandhi Ravi
 
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
 
Storage classes arrays & functions in C Language
Storage classes arrays & functions in C LanguageStorage classes arrays & functions in C Language
Storage classes arrays & functions in C LanguageJenish Bhavsar
 
Pro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScriptPro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScriptSeok-joon Yun
 
presentation_functions_1443207686_140676.ppt
presentation_functions_1443207686_140676.pptpresentation_functions_1443207686_140676.ppt
presentation_functions_1443207686_140676.pptSandipPradhan23
 
Data structure scope of variables
Data structure scope of variablesData structure scope of variables
Data structure scope of variablesSaurav Kumar
 
Chap2 class,objects
Chap2 class,objectsChap2 class,objects
Chap2 class,objectsraksharao
 
Advanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sirAdvanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sirAVINASH KUMAR
 
java_bba_21_vision academy_final.pdf
java_bba_21_vision academy_final.pdfjava_bba_21_vision academy_final.pdf
java_bba_21_vision academy_final.pdfakankshasorate1
 

Similaire à storage class (20)

Storage class in C Language
Storage class in C LanguageStorage class in C Language
Storage class in C Language
 
Storage class
Storage classStorage class
Storage class
 
Java ppt Gandhi Ravi (gandhiri@gmail.com)
Java ppt  Gandhi Ravi  (gandhiri@gmail.com)Java ppt  Gandhi Ravi  (gandhiri@gmail.com)
Java ppt Gandhi Ravi (gandhiri@gmail.com)
 
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 class
Storage classStorage class
Storage class
 
Storage class
Storage classStorage class
Storage class
 
Storage classes arrays & functions in C Language
Storage classes arrays & functions in C LanguageStorage classes arrays & functions in C Language
Storage classes arrays & functions in C Language
 
Pro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScriptPro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScript
 
Storage classes
Storage classesStorage classes
Storage classes
 
5.program structure
5.program structure5.program structure
5.program structure
 
presentation_functions_1443207686_140676.ppt
presentation_functions_1443207686_140676.pptpresentation_functions_1443207686_140676.ppt
presentation_functions_1443207686_140676.ppt
 
What is inheritance
What is inheritanceWhat is inheritance
What is inheritance
 
Java doc Pr ITM2
Java doc Pr ITM2Java doc Pr ITM2
Java doc Pr ITM2
 
Storage Class
Storage ClassStorage Class
Storage Class
 
Data structure scope of variables
Data structure scope of variablesData structure scope of variables
Data structure scope of variables
 
Lecture 13 - Storage Classes
Lecture 13 - Storage ClassesLecture 13 - Storage Classes
Lecture 13 - Storage Classes
 
Chap2 class,objects
Chap2 class,objectsChap2 class,objects
Chap2 class,objects
 
Advanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sirAdvanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sir
 
java_bba_21_vision academy_final.pdf
java_bba_21_vision academy_final.pdfjava_bba_21_vision academy_final.pdf
java_bba_21_vision academy_final.pdf
 

Plus de student

Logic Gates
Logic GatesLogic Gates
Logic Gatesstudent
 
Flipflops and Excitation tables of flipflops
Flipflops and Excitation tables of flipflopsFlipflops and Excitation tables of flipflops
Flipflops and Excitation tables of flipflopsstudent
 
Number Systems
Number SystemsNumber Systems
Number Systemsstudent
 
towers of hanoi
towers of hanoitowers of hanoi
towers of hanoistudent
 
header, circular and two way linked lists
header, circular and two way linked listsheader, circular and two way linked lists
header, circular and two way linked listsstudent
 
Arrays Data Structure
Arrays Data StructureArrays Data Structure
Arrays Data Structurestudent
 
Number Systems
Number SystemsNumber Systems
Number Systemsstudent
 
binary arithmetic rules
binary arithmetic rulesbinary arithmetic rules
binary arithmetic rulesstudent
 
BCD,GRAY and EXCESS 3 codes
BCD,GRAY and EXCESS 3 codesBCD,GRAY and EXCESS 3 codes
BCD,GRAY and EXCESS 3 codesstudent
 
animals colours numbers idioms
animals colours numbers idiomsanimals colours numbers idioms
animals colours numbers idiomsstudent
 
irregular verbs
irregular verbsirregular verbs
irregular verbsstudent
 
dc generator ece
dc generator ecedc generator ece
dc generator ecestudent
 
INDUCTION MOTOR
INDUCTION MOTORINDUCTION MOTOR
INDUCTION MOTORstudent
 
structure and union
structure and unionstructure and union
structure and unionstudent
 
file handling1
file handling1file handling1
file handling1student
 
direct and indirect band gap
direct and indirect band gapdirect and indirect band gap
direct and indirect band gapstudent
 
hall effect
hall effecthall effect
hall effectstudent
 
optics chapter_07_solution_manual
optics chapter_07_solution_manualoptics chapter_07_solution_manual
optics chapter_07_solution_manualstudent
 
dyneins and kinesins
dyneins and kinesinsdyneins and kinesins
dyneins and kinesinsstudent
 
Structure and function of bacterial cells
Structure and function of bacterial cellsStructure and function of bacterial cells
Structure and function of bacterial cellsstudent
 

Plus de student (20)

Logic Gates
Logic GatesLogic Gates
Logic Gates
 
Flipflops and Excitation tables of flipflops
Flipflops and Excitation tables of flipflopsFlipflops and Excitation tables of flipflops
Flipflops and Excitation tables of flipflops
 
Number Systems
Number SystemsNumber Systems
Number Systems
 
towers of hanoi
towers of hanoitowers of hanoi
towers of hanoi
 
header, circular and two way linked lists
header, circular and two way linked listsheader, circular and two way linked lists
header, circular and two way linked lists
 
Arrays Data Structure
Arrays Data StructureArrays Data Structure
Arrays Data Structure
 
Number Systems
Number SystemsNumber Systems
Number Systems
 
binary arithmetic rules
binary arithmetic rulesbinary arithmetic rules
binary arithmetic rules
 
BCD,GRAY and EXCESS 3 codes
BCD,GRAY and EXCESS 3 codesBCD,GRAY and EXCESS 3 codes
BCD,GRAY and EXCESS 3 codes
 
animals colours numbers idioms
animals colours numbers idiomsanimals colours numbers idioms
animals colours numbers idioms
 
irregular verbs
irregular verbsirregular verbs
irregular verbs
 
dc generator ece
dc generator ecedc generator ece
dc generator ece
 
INDUCTION MOTOR
INDUCTION MOTORINDUCTION MOTOR
INDUCTION MOTOR
 
structure and union
structure and unionstructure and union
structure and union
 
file handling1
file handling1file handling1
file handling1
 
direct and indirect band gap
direct and indirect band gapdirect and indirect band gap
direct and indirect band gap
 
hall effect
hall effecthall effect
hall effect
 
optics chapter_07_solution_manual
optics chapter_07_solution_manualoptics chapter_07_solution_manual
optics chapter_07_solution_manual
 
dyneins and kinesins
dyneins and kinesinsdyneins and kinesins
dyneins and kinesins
 
Structure and function of bacterial cells
Structure and function of bacterial cellsStructure and function of bacterial cells
Structure and function of bacterial cells
 

Dernier

Appkodes Tinder Clone Script with Customisable Solutions.pptx
Appkodes Tinder Clone Script with Customisable Solutions.pptxAppkodes Tinder Clone Script with Customisable Solutions.pptx
Appkodes Tinder Clone Script with Customisable Solutions.pptxappkodes
 
8447779800, Low rate Call girls in Tughlakabad Delhi NCR
8447779800, Low rate Call girls in Tughlakabad Delhi NCR8447779800, Low rate Call girls in Tughlakabad Delhi NCR
8447779800, Low rate Call girls in Tughlakabad Delhi NCRashishs7044
 
International Business Environments and Operations 16th Global Edition test b...
International Business Environments and Operations 16th Global Edition test b...International Business Environments and Operations 16th Global Edition test b...
International Business Environments and Operations 16th Global Edition test b...ssuserf63bd7
 
Ten Organizational Design Models to align structure and operations to busines...
Ten Organizational Design Models to align structure and operations to busines...Ten Organizational Design Models to align structure and operations to busines...
Ten Organizational Design Models to align structure and operations to busines...Seta Wicaksana
 
PSCC - Capability Statement Presentation
PSCC - Capability Statement PresentationPSCC - Capability Statement Presentation
PSCC - Capability Statement PresentationAnamaria Contreras
 
FULL ENJOY Call girls in Paharganj Delhi | 8377087607
FULL ENJOY Call girls in Paharganj Delhi | 8377087607FULL ENJOY Call girls in Paharganj Delhi | 8377087607
FULL ENJOY Call girls in Paharganj Delhi | 8377087607dollysharma2066
 
APRIL2024_UKRAINE_xml_0000000000000 .pdf
APRIL2024_UKRAINE_xml_0000000000000 .pdfAPRIL2024_UKRAINE_xml_0000000000000 .pdf
APRIL2024_UKRAINE_xml_0000000000000 .pdfRbc Rbcua
 
1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdf1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdfShaun Heinrichs
 
Innovation Conference 5th March 2024.pdf
Innovation Conference 5th March 2024.pdfInnovation Conference 5th March 2024.pdf
Innovation Conference 5th March 2024.pdfrichard876048
 
Memorándum de Entendimiento (MoU) entre Codelco y SQM
Memorándum de Entendimiento (MoU) entre Codelco y SQMMemorándum de Entendimiento (MoU) entre Codelco y SQM
Memorándum de Entendimiento (MoU) entre Codelco y SQMVoces Mineras
 
Annual General Meeting Presentation Slides
Annual General Meeting Presentation SlidesAnnual General Meeting Presentation Slides
Annual General Meeting Presentation SlidesKeppelCorporation
 
Financial-Statement-Analysis-of-Coca-cola-Company.pptx
Financial-Statement-Analysis-of-Coca-cola-Company.pptxFinancial-Statement-Analysis-of-Coca-cola-Company.pptx
Financial-Statement-Analysis-of-Coca-cola-Company.pptxsaniyaimamuddin
 
Unlocking the Future: Explore Web 3.0 Workshop to Start Earning Today!
Unlocking the Future: Explore Web 3.0 Workshop to Start Earning Today!Unlocking the Future: Explore Web 3.0 Workshop to Start Earning Today!
Unlocking the Future: Explore Web 3.0 Workshop to Start Earning Today!Doge Mining Website
 
Market Sizes Sample Report - 2024 Edition
Market Sizes Sample Report - 2024 EditionMarket Sizes Sample Report - 2024 Edition
Market Sizes Sample Report - 2024 EditionMintel Group
 
TriStar Gold Corporate Presentation - April 2024
TriStar Gold Corporate Presentation - April 2024TriStar Gold Corporate Presentation - April 2024
TriStar Gold Corporate Presentation - April 2024Adnet Communications
 
PB Project 1: Exploring Your Personal Brand
PB Project 1: Exploring Your Personal BrandPB Project 1: Exploring Your Personal Brand
PB Project 1: Exploring Your Personal BrandSharisaBethune
 
Flow Your Strategy at Flight Levels Day 2024
Flow Your Strategy at Flight Levels Day 2024Flow Your Strategy at Flight Levels Day 2024
Flow Your Strategy at Flight Levels Day 2024Kirill Klimov
 
8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR
8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR
8447779800, Low rate Call girls in Shivaji Enclave Delhi NCRashishs7044
 
Kenya Coconut Production Presentation by Dr. Lalith Perera
Kenya Coconut Production Presentation by Dr. Lalith PereraKenya Coconut Production Presentation by Dr. Lalith Perera
Kenya Coconut Production Presentation by Dr. Lalith Pereraictsugar
 

Dernier (20)

Appkodes Tinder Clone Script with Customisable Solutions.pptx
Appkodes Tinder Clone Script with Customisable Solutions.pptxAppkodes Tinder Clone Script with Customisable Solutions.pptx
Appkodes Tinder Clone Script with Customisable Solutions.pptx
 
8447779800, Low rate Call girls in Tughlakabad Delhi NCR
8447779800, Low rate Call girls in Tughlakabad Delhi NCR8447779800, Low rate Call girls in Tughlakabad Delhi NCR
8447779800, Low rate Call girls in Tughlakabad Delhi NCR
 
International Business Environments and Operations 16th Global Edition test b...
International Business Environments and Operations 16th Global Edition test b...International Business Environments and Operations 16th Global Edition test b...
International Business Environments and Operations 16th Global Edition test b...
 
Ten Organizational Design Models to align structure and operations to busines...
Ten Organizational Design Models to align structure and operations to busines...Ten Organizational Design Models to align structure and operations to busines...
Ten Organizational Design Models to align structure and operations to busines...
 
PSCC - Capability Statement Presentation
PSCC - Capability Statement PresentationPSCC - Capability Statement Presentation
PSCC - Capability Statement Presentation
 
FULL ENJOY Call girls in Paharganj Delhi | 8377087607
FULL ENJOY Call girls in Paharganj Delhi | 8377087607FULL ENJOY Call girls in Paharganj Delhi | 8377087607
FULL ENJOY Call girls in Paharganj Delhi | 8377087607
 
Corporate Profile 47Billion Information Technology
Corporate Profile 47Billion Information TechnologyCorporate Profile 47Billion Information Technology
Corporate Profile 47Billion Information Technology
 
APRIL2024_UKRAINE_xml_0000000000000 .pdf
APRIL2024_UKRAINE_xml_0000000000000 .pdfAPRIL2024_UKRAINE_xml_0000000000000 .pdf
APRIL2024_UKRAINE_xml_0000000000000 .pdf
 
1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdf1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdf
 
Innovation Conference 5th March 2024.pdf
Innovation Conference 5th March 2024.pdfInnovation Conference 5th March 2024.pdf
Innovation Conference 5th March 2024.pdf
 
Memorándum de Entendimiento (MoU) entre Codelco y SQM
Memorándum de Entendimiento (MoU) entre Codelco y SQMMemorándum de Entendimiento (MoU) entre Codelco y SQM
Memorándum de Entendimiento (MoU) entre Codelco y SQM
 
Annual General Meeting Presentation Slides
Annual General Meeting Presentation SlidesAnnual General Meeting Presentation Slides
Annual General Meeting Presentation Slides
 
Financial-Statement-Analysis-of-Coca-cola-Company.pptx
Financial-Statement-Analysis-of-Coca-cola-Company.pptxFinancial-Statement-Analysis-of-Coca-cola-Company.pptx
Financial-Statement-Analysis-of-Coca-cola-Company.pptx
 
Unlocking the Future: Explore Web 3.0 Workshop to Start Earning Today!
Unlocking the Future: Explore Web 3.0 Workshop to Start Earning Today!Unlocking the Future: Explore Web 3.0 Workshop to Start Earning Today!
Unlocking the Future: Explore Web 3.0 Workshop to Start Earning Today!
 
Market Sizes Sample Report - 2024 Edition
Market Sizes Sample Report - 2024 EditionMarket Sizes Sample Report - 2024 Edition
Market Sizes Sample Report - 2024 Edition
 
TriStar Gold Corporate Presentation - April 2024
TriStar Gold Corporate Presentation - April 2024TriStar Gold Corporate Presentation - April 2024
TriStar Gold Corporate Presentation - April 2024
 
PB Project 1: Exploring Your Personal Brand
PB Project 1: Exploring Your Personal BrandPB Project 1: Exploring Your Personal Brand
PB Project 1: Exploring Your Personal Brand
 
Flow Your Strategy at Flight Levels Day 2024
Flow Your Strategy at Flight Levels Day 2024Flow Your Strategy at Flight Levels Day 2024
Flow Your Strategy at Flight Levels Day 2024
 
8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR
8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR
8447779800, Low rate Call girls in Shivaji Enclave Delhi NCR
 
Kenya Coconut Production Presentation by Dr. Lalith Perera
Kenya Coconut Production Presentation by Dr. Lalith PereraKenya Coconut Production Presentation by Dr. Lalith Perera
Kenya Coconut Production Presentation by Dr. Lalith Perera
 

storage class

  • 1. Storage Classes( Characteristics of Variable ) Prepared By Vishnu Sharma(MCA) www.examengine.info Prepared By Vishnu Sharma(MCA) for www.examengine.info
  • 2. Meaning of Storage Class Each variable declared in C contains not only its data type but also it has a storage class specified with it. If user do not specify the storage class of a variable , the compiler will assume its storage class as default i.e. automatic . Prepared By Vishnu Sharma(MCA) for www.examengine.info
  • 3. Purpose of Storage Class The storage class of a variable tells us about :- I. Storage Place of Variable i.e. Memory or CPU Registers II. Initial value of Variable III. Scope of Variable IV. Lifetime of Variable i.e. how long variable exists. Prepared By Vishnu Sharma(MCA) for www.examengine.info
  • 4. How Storage Class Declared ???? auto int a ,b ; Storage Class Data Type Variable Prepared By Vishnu Sharma(MCA) for www.examengine.info
  • 5. Four Type of Storage Class in C Language :-  Automatic Storage Class ( Local Variables )  Register Storage Class  Static Storage Class  External Storage Class Prepared By Vishnu Sharma(MCA) for www.examengine.info
  • 6. Automatic Storage Class Characteristi cs Meaning Storage Memory Initial Value Garbage Value i.e. An Unpredictable Value. Scope or Visibility Local or Visible in the Block in which it is declared. Life Time It retains its value till it is in the block in which it is declared. This is the default storage class for all the variable . It always reinitialize the value of variable .It is declared as : - auto int a ; Prepared By Vishnu Sharma(MCA) for www.examengine.info
  • 7. Void main ( ) { auto int i , j = 5 ; int k ,m =10 ; // By Default Automatic Storage Class printf ( “ value of i = % d n value of j = % d “ , i , j ) ; printf ( “ value of k = % d n value of m = % d “ , i , j ) ; } Value of i = 2009 Value of j = 5 Value of k = 1005 Value of m = 10 Garbage Value Variable Value Use of Automatic Storage Class Prepared By Vishnu Sharma(MCA) for www.examengine.info
  • 8. #include<stdio.h> int main() { auto int i=1; {  auto int i=2;  {  auto int i=3;  printf(“%d”,i);  }  printf(“%d”,i);  } printf(“%d”,i);  return 0;Prepared By Vishnu Sharma(MCA) for www.examengine.info
  • 9. Use of Automatic Storage Class void ck ( ) ; void main( ) { clrscr ( ) ; ck ( ) ; ck ( ) ; ck ( ) ; getch( ) ; } void ck ( ) { int i = 0 ; printf ( “nn Value of I ..%d”,i ) ; i + + ; } Output 0 0 0 Prepared By Vishnu Sharma(MCA) for www.examengine.info
  • 10. Register Storage Class Characteristic s Meaning Storage C P U Registers Initial Value Garbage Value Scope or Visibility Local to the Block in which it is declared Life Time It retains its value till the control remains in the block In this storage class , variable is stored in C P U Registers , just for the sake of increase the execution speed of some variable of program. It is declares as :- register int a ; Prepared By Vishnu Sharma(MCA) for www.examengine.info
  • 11. Void main ( ) { register int i ; for ( i = 1 ; i < = 100 ; i + + ) { printf ( “ n % d “ , i ) ; } } Use of Register Storage Class Prepared By Vishnu Sharma(MCA) for www.examengine.info
  • 12. Static Storage Class This storage class is used when a user want that a variable should retain its value even after the execution of the function in which it is declared, then this storage class is used . It is declared as follow :- static int a ; Characteristic s Meaning Storage Memory Initial Value Zero ( 0 ) Scope or Visibility Local to the block in which it is declared Life Time It retains its value between the different functionPrepared By Vishnu Sharma(MCA) for www.examengine.info
  • 13. Use of Static Storage Class void ck ( ) ; void main( ) { clrscr ( ) ; ck ( ) ; ck ( ) ; ck ( ) ; getch( ) ; } void ck ( ) { static int i = 0 ; printf ( “nn Value of I ..%d”,i ) ; i + + ; } Output 0 1 2 Prepared By Vishnu Sharma(MCA) for www.examengine.info
  • 14. External Storage Class Characteristic s Meaning Storage Memory Initial Value Zero ( 0 ) Scope or Visibility Global ( Visible in all the Program ) Life Time It retains its value through out the whole program External variables are declared outside all functions i.e, at the beginning of the program. Global variables should be available to all the functions with the help of extern specifier. It is declared as follow : - extern int a ; Prepared By Vishnu Sharma(MCA) for www.examengine.info
  • 15. Use of External Storage Class extern int a = 10 ; void ck ( ) ; void main( ) { int a = 5 ; printf ( “ %d “ , a) ; ck ( ) ; getch ( ) ; } void ck ( ) { a = a + 10 ; printf ( “nn Value of a ..%d”,a ) ; } Output 5 20 Prepared By Vishnu Sharma(MCA) for www.examengine.info