SlideShare ist ein Scribd-Unternehmen logo
1 von 17
Disclaimer: This presentation is prepared by trainees of
baabtra as a part of mentoring program. This is not official
document of baabtra –Mentoring Partner
Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt .
Ltd
Scope of variables
Jaseena A P
jsnp65@gmail.com
www.facebook.com/Jaseena
Muhammed A P
twitter.com/username
in.linkedin.com/in/profilena
me
9539443588
WHAT IS A VARIABLE?
In computer programming, a variable is a storage
location and an associated symbolic
name (an identifier) which contains some known or
unknown quantity or information, a value.
 The variable name is the usual way to reference the
stored value; this separation of name and content
allows the name to be used independently of the
exact information it represents.
WHAT IS SCOPE?
 The part of a computer program where the identifier,
can be used to find the referred entity.
Scoping rules are crucial in modular programming, so a
change in one part of the program does not break an
unrelated part.
SCOPE (CONTD…)
Lexical Dynamic
Scope
Local Global
SCOPE (CONTD…)
 In lexical scoping (or lexical scope; also called static
scoping or static scope), if a variable name's scope
is a certain function, then its scope is the program
text of the function definition.
 In dynamic scoping (or dynamic scope), if a variable
name's scope is a certain function, then its scope is
the time-period during which the function is
executing.
LEVELS OF SCOPE
 Expression scope
 Block scope
 Function scope
 Module scope
 File/Global scope
Local scope
Global scope
LEVELS OF SCOPE(contd…)
 Expression scope: A declaration's scope is a single
expression.
eg:-int sum(int a,int b);
 Block scope: scope is restricted to a block.
Eg:-char a;
switch(a)
{
case y:
//do something
case n:
//do something
}
LEVELS OF SCOPE(contd…)
 Function scope: Scope of the variable is restricted
to the body of the function which declared it.
void sum(int a,int b)
{
int c;// c is alive inside sum() only.
}
void main()
{
int sm;//sm is alive in main() only
}
 Module scope: In modular programming, the scope of
a name can be an entire module, however it may be
structured across various files.
Eg:- Python
 Global/File scope: A declaration has global scope if it
has effect throughout an entire program. Variable
names with global scope are frequently considered bad
practice due to the possibility of name collisions.
LEVELS OF SCOPE(contd..)
LEVELS OF SCOPE(contd…)
Example for global(global/file scope)
variable
int year = 1994; // global variable
int Max (int, int); // global function
int main (void) // global function
{ //... }
Local vs Global scope
int xyz; // xyz is global
void Foo (int xyz) // xyz is local to the body
of Foo
{ if (xyz > 0)
{ double xyz; // xyz is local to this block //...
}
}
THANK YOU
If this presentation helped you, please visit our
page facebook.com/baabtra and like it.
Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com
Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

SEMINAR
SEMINARSEMINAR
SEMINAR
 
Why C is Called Structured Programming Language
Why C is Called Structured Programming LanguageWhy C is Called Structured Programming Language
Why C is Called Structured Programming Language
 
OOP in java
OOP in javaOOP in java
OOP in java
 
OOP in C++
OOP in C++OOP in C++
OOP in C++
 
C language
C languageC language
C language
 
C vs c++
C vs c++C vs c++
C vs c++
 
Object-Oriented Polymorphism Unleashed
Object-Oriented Polymorphism UnleashedObject-Oriented Polymorphism Unleashed
Object-Oriented Polymorphism Unleashed
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
 
structured programming Introduction to c fundamentals
structured programming Introduction to c fundamentalsstructured programming Introduction to c fundamentals
structured programming Introduction to c fundamentals
 
Presentation c
Presentation cPresentation c
Presentation c
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Interfaces
InterfacesInterfaces
Interfaces
 
Object oriented programming c++
Object oriented programming c++Object oriented programming c++
Object oriented programming c++
 
General OOP Concepts
General OOP ConceptsGeneral OOP Concepts
General OOP Concepts
 
difference between c c++ c#
difference between c c++ c#difference between c c++ c#
difference between c c++ c#
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and looping
 
Basic structure of C++ program
Basic structure of C++ programBasic structure of C++ program
Basic structure of C++ program
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Structure of C program
Structure of C programStructure of C program
Structure of C program
 
Differences between c and c++
Differences between c and c++Differences between c and c++
Differences between c and c++
 

Andere mochten auch (6)

Scrum 100
Scrum 100Scrum 100
Scrum 100
 
Odyssey Claims
Odyssey ClaimsOdyssey Claims
Odyssey Claims
 
Oop concept
Oop conceptOop concept
Oop concept
 
Presentation for the "Best Active Tourism Product" Competition in 2010
Presentation for the "Best Active Tourism Product" Competition in 2010Presentation for the "Best Active Tourism Product" Competition in 2010
Presentation for the "Best Active Tourism Product" Competition in 2010
 
Samsung Product Presentation
Samsung Product PresentationSamsung Product Presentation
Samsung Product Presentation
 
Marketing Plan New Product
Marketing Plan New ProductMarketing Plan New Product
Marketing Plan New Product
 

Ähnlich wie Scope of variable

Intro Java Rev010
Intro Java Rev010Intro Java Rev010
Intro Java Rev010
Rich Helton
 
OOP-Advanced Programming with c++
OOP-Advanced Programming with c++OOP-Advanced Programming with c++
OOP-Advanced Programming with c++
Mohamed Essam
 
Data structure scope of variables
Data structure scope of variablesData structure scope of variables
Data structure scope of variables
Saurav Kumar
 
INDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptx
INDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptxINDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptx
INDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptx
Indu65
 

Ähnlich wie Scope of variable (20)

Scope of variables
Scope of variablesScope of variables
Scope of variables
 
Scope of variables
Scope of variablesScope of variables
Scope of variables
 
4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT
 
Basic construction of c
Basic construction of cBasic construction of c
Basic construction of c
 
Intro Java Rev010
Intro Java Rev010Intro Java Rev010
Intro Java Rev010
 
PCCF UNIT 2.pptx
PCCF UNIT 2.pptxPCCF UNIT 2.pptx
PCCF UNIT 2.pptx
 
Scope of variables
Scope of variablesScope of variables
Scope of variables
 
PCCF UNIT 2 CLASS.pptx
PCCF UNIT 2 CLASS.pptxPCCF UNIT 2 CLASS.pptx
PCCF UNIT 2 CLASS.pptx
 
C language updated
C language updatedC language updated
C language updated
 
FUNCTIONS.pptx
FUNCTIONS.pptxFUNCTIONS.pptx
FUNCTIONS.pptx
 
SPL 9 | Scope of Variables in C
SPL 9 | Scope of Variables in CSPL 9 | Scope of Variables in C
SPL 9 | Scope of Variables in C
 
C tutorials
C tutorialsC tutorials
C tutorials
 
Password protected diary
Password protected diaryPassword protected diary
Password protected diary
 
OOP-Advanced Programming with c++
OOP-Advanced Programming with c++OOP-Advanced Programming with c++
OOP-Advanced Programming with c++
 
Library management system
Library management systemLibrary management system
Library management system
 
Data structure scope of variables
Data structure scope of variablesData structure scope of variables
Data structure scope of variables
 
Operator Overloading and Scope of Variable
Operator Overloading and Scope of VariableOperator Overloading and Scope of Variable
Operator Overloading and Scope of Variable
 
INDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptx
INDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptxINDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptx
INDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptx
 
Chapter-3 Scoping.pptx
Chapter-3 Scoping.pptxChapter-3 Scoping.pptx
Chapter-3 Scoping.pptx
 
Mi0041 java and web design
Mi0041  java and web designMi0041  java and web design
Mi0041 java and web design
 

Mehr von baabtra.com - No. 1 supplier of quality freshers

Mehr von baabtra.com - No. 1 supplier of quality freshers (20)

Agile methodology and scrum development
Agile methodology and scrum developmentAgile methodology and scrum development
Agile methodology and scrum development
 
Best coding practices
Best coding practicesBest coding practices
Best coding practices
 
Core java - baabtra
Core java - baabtraCore java - baabtra
Core java - baabtra
 
Acquiring new skills what you should know
Acquiring new skills   what you should knowAcquiring new skills   what you should know
Acquiring new skills what you should know
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
 
99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love 99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love
 
Php sessions & cookies
Php sessions & cookiesPhp sessions & cookies
Php sessions & cookies
 
Php database connectivity
Php database connectivityPhp database connectivity
Php database connectivity
 
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Microsoft holo lens
 
Blue brain
Blue brainBlue brain
Blue brain
 
5g
5g5g
5g
 
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra
Aptitude skills baabtra
 
Gd baabtra
Gd baabtraGd baabtra
Gd baabtra
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

Scope of variable

  • 1.
  • 2. Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring Partner Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
  • 3.
  • 4. Scope of variables Jaseena A P jsnp65@gmail.com www.facebook.com/Jaseena Muhammed A P twitter.com/username in.linkedin.com/in/profilena me 9539443588
  • 5. WHAT IS A VARIABLE? In computer programming, a variable is a storage location and an associated symbolic name (an identifier) which contains some known or unknown quantity or information, a value.  The variable name is the usual way to reference the stored value; this separation of name and content allows the name to be used independently of the exact information it represents.
  • 6. WHAT IS SCOPE?  The part of a computer program where the identifier, can be used to find the referred entity. Scoping rules are crucial in modular programming, so a change in one part of the program does not break an unrelated part.
  • 8. SCOPE (CONTD…)  In lexical scoping (or lexical scope; also called static scoping or static scope), if a variable name's scope is a certain function, then its scope is the program text of the function definition.  In dynamic scoping (or dynamic scope), if a variable name's scope is a certain function, then its scope is the time-period during which the function is executing.
  • 9. LEVELS OF SCOPE  Expression scope  Block scope  Function scope  Module scope  File/Global scope Local scope Global scope
  • 10. LEVELS OF SCOPE(contd…)  Expression scope: A declaration's scope is a single expression. eg:-int sum(int a,int b);  Block scope: scope is restricted to a block. Eg:-char a; switch(a) { case y: //do something case n: //do something }
  • 11. LEVELS OF SCOPE(contd…)  Function scope: Scope of the variable is restricted to the body of the function which declared it. void sum(int a,int b) { int c;// c is alive inside sum() only. } void main() { int sm;//sm is alive in main() only }
  • 12.  Module scope: In modular programming, the scope of a name can be an entire module, however it may be structured across various files. Eg:- Python  Global/File scope: A declaration has global scope if it has effect throughout an entire program. Variable names with global scope are frequently considered bad practice due to the possibility of name collisions. LEVELS OF SCOPE(contd..)
  • 13. LEVELS OF SCOPE(contd…) Example for global(global/file scope) variable int year = 1994; // global variable int Max (int, int); // global function int main (void) // global function { //... }
  • 14. Local vs Global scope int xyz; // xyz is global void Foo (int xyz) // xyz is local to the body of Foo { if (xyz > 0) { double xyz; // xyz is local to this block //... } }
  • 16. If this presentation helped you, please visit our page facebook.com/baabtra and like it. Thanks in advance. www.baabtra.com | www.massbaab.com |www.baabte.com
  • 17. Contact Us Emarald Mall (Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Start up Village Eranakulam, Kerala, India. Email: info@baabtra.com