SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

La actualidad más candente

Storage classes in C
Storage classes in C Storage classes in C
Storage classes in C Self employed
 
Operators in c programming
Operators in c programmingOperators in c programming
Operators in c programmingsavitamhaske
 
Chapter 2 : Balagurusamy_ Programming ANsI in C
Chapter 2 :  Balagurusamy_ Programming ANsI in CChapter 2 :  Balagurusamy_ Programming ANsI in C
Chapter 2 : Balagurusamy_ Programming ANsI in CBUBT
 
Chapter 3 : Balagurusamy Programming ANSI in C
Chapter 3 : Balagurusamy Programming ANSI in C Chapter 3 : Balagurusamy Programming ANSI in C
Chapter 3 : Balagurusamy Programming ANSI in C BUBT
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.Haard Shah
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructorsVineeta Garg
 
Python Basics
Python BasicsPython Basics
Python BasicsPooja B S
 
Decision making statements in C programming
Decision making statements in C programmingDecision making statements in C programming
Decision making statements in C programmingRabin BK
 
Function in c program
Function in c programFunction in c program
Function in c programumesh patil
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorialsMayank Jain
 

La actualidad más candente (20)

Scope of variables
Scope of variablesScope of variables
Scope of variables
 
Storage classes in C
Storage classes in C Storage classes in C
Storage classes in C
 
Operators in c programming
Operators in c programmingOperators in c programming
Operators in c programming
 
Chapter 2 : Balagurusamy_ Programming ANsI in C
Chapter 2 :  Balagurusamy_ Programming ANsI in CChapter 2 :  Balagurusamy_ Programming ANsI in C
Chapter 2 : Balagurusamy_ Programming ANsI in C
 
Chapter 3 : Balagurusamy Programming ANSI in C
Chapter 3 : Balagurusamy Programming ANSI in C Chapter 3 : Balagurusamy Programming ANSI in C
Chapter 3 : Balagurusamy Programming ANSI in C
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.
 
Inheritance and Polymorphism
Inheritance and PolymorphismInheritance and Polymorphism
Inheritance and Polymorphism
 
Strings
StringsStrings
Strings
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
 
Python Basics
Python BasicsPython Basics
Python Basics
 
Decision making statements in C programming
Decision making statements in C programmingDecision making statements in C programming
Decision making statements in C programming
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
 
Unions in c
Unions in cUnions in c
Unions in c
 
Function in c program
Function in c programFunction in c program
Function in c program
 
Storage classes
Storage classesStorage classes
Storage classes
 
Control flow statements in java
Control flow statements in javaControl flow statements in java
Control flow statements in java
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorials
 
Java exception handling
Java exception handlingJava exception handling
Java exception handling
 
Unary operator overloading
Unary operator overloadingUnary operator overloading
Unary operator overloading
 
pre processor directives in C
pre processor directives in Cpre processor directives in C
pre processor directives in C
 

Similar a storage class

Similar a storage class (20)

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
 
6. static keyword
6. static keyword6. static keyword
6. static keyword
 

Más 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
 

Más 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
 

Último

Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...lizamodels9
 
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...amitlee9823
 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...Aggregage
 
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Dipal Arora
 
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangaloreamitlee9823
 
How to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League CityHow to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League CityEric T. Tung
 
Pharma Works Profile of Karan Communications
Pharma Works Profile of Karan CommunicationsPharma Works Profile of Karan Communications
Pharma Works Profile of Karan Communicationskarancommunications
 
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfDr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfAdmir Softic
 
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Dave Litwiller
 
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...amitlee9823
 
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesMysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesDipal Arora
 
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptxB.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptxpriyanshujha201
 
HONOR Veterans Event Keynote by Michael Hawkins
HONOR Veterans Event Keynote by Michael HawkinsHONOR Veterans Event Keynote by Michael Hawkins
HONOR Veterans Event Keynote by Michael HawkinsMichael W. Hawkins
 
7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...Paul Menig
 
VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒anilsa9823
 
Monthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxMonthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxAndy Lambert
 
Organizational Transformation Lead with Culture
Organizational Transformation Lead with CultureOrganizational Transformation Lead with Culture
Organizational Transformation Lead with CultureSeta Wicaksana
 

Último (20)

Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
 
Forklift Operations: Safety through Cartoons
Forklift Operations: Safety through CartoonsForklift Operations: Safety through Cartoons
Forklift Operations: Safety through Cartoons
 
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
 
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabiunwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
 
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
 
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
 
How to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League CityHow to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League City
 
Pharma Works Profile of Karan Communications
Pharma Works Profile of Karan CommunicationsPharma Works Profile of Karan Communications
Pharma Works Profile of Karan Communications
 
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfDr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
 
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
 
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
 
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesMysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
 
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptxB.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
 
HONOR Veterans Event Keynote by Michael Hawkins
HONOR Veterans Event Keynote by Michael HawkinsHONOR Veterans Event Keynote by Michael Hawkins
HONOR Veterans Event Keynote by Michael Hawkins
 
7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...
 
VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒
 
Monthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxMonthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptx
 
VVVIP Call Girls In Greater Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Greater Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...VVVIP Call Girls In Greater Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Greater Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
 
Organizational Transformation Lead with Culture
Organizational Transformation Lead with CultureOrganizational Transformation Lead with Culture
Organizational Transformation Lead with Culture
 

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