Scope of variables

16

description

Scope of variables

Transcript of Scope of variables

Page 1: Scope of variables
Page 2: Scope of variables

Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring PartnerBaabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd

Page 3: Scope of variables

Syed Maharoof thangal cmahroof917@@gmail.comwww.facebook.com/syed mahrooftwitter.com/syed mahroofin.linkedin.com/in/syed mahroof

Scope of Variables

Page 4: Scope of variables

A variable is nothing but a name given to a storage area that our program can manipulate.

Each variable in C has a specific type,◦ Size and layout◦ Range◦ Set of operations

Variable

Page 5: Scope of variables

Char Int Flaot Double void

Types of variables

Page 6: Scope of variables

An objective C program will consist of code divided up into functions, classes , and code structures

A typical program will make extensive use of variable to store and manipulate data

Once a variable declared it may or may not be accessible to other section of program code

This accessibility depends on where and how the variable was declared and where the code is that needed to access .This is known as variable scope

Scope of variables

Page 7: Scope of variables

Local Variables

Global variables

Types of Variables

Page 8: Scope of variables

Variable that are declared inside a function or block called local variables

They can be used only by statements that are inside that function or block of code

Local variable not known to functions outside

Local variables

Page 9: Scope of variables

Here all the variables x , y and z are declared inside the main , so it is local to main() functions

Example

Page 10: Scope of variables

Global variables are defined outside of a function , usually on top of the program

The global variables will hold their value throughout the lifetime of your program and they can be accessed inside any functions defined for the program

A global variable can be accessed by any function

Global variable is available for use throughout your entire program after its declaration

Global variables

Page 11: Scope of variables

Example

Page 12: Scope of variables

A program can have same name for local and global variables

But value of local variables inside a function will take preference

Page 13: Scope of variables
Page 14: Scope of variables

Want to learn more about programming or Looking to become a good programmer?

Are you wasting time on searching so many contents online?

Do you want to learn things quickly?

Tired of spending huge amount of money to become a Software professional?

Do an online course @ baabtra.com

We put industry standards to practice. Our structured, activity based courses are so designed to make a quick, good software professional out of anybody who holds a passion for coding.

Page 15: Scope of variables

Follow us @ twitter.com/baabtra

Like us @ facebook.com/baabtra

Subscribe to us @ youtube.com/baabtra

Become a follower @ slideshare.net/BaabtraMentoringPartner

Connect to us @ in.linkedin.com/in/baabtra

Thanks in advance.  

www.baabtra.com | www.massbaab.com |www.baabte.com

Page 16: Scope of variables

Contact Us

Emarald Mall (Big Bazar Building)Mavoor Road, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550

NC Complex, Near Bus StandMukkam, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550

Cafit Square,Hilite Business Park,Near Pantheerankavu,Kozhikode

Start up VillageEranakulam,Kerala, India.

Email: [email protected]