Scope of variables
-
Upload
baabtracom-first-coding-school-in-india -
Category
Technology
-
view
310 -
download
0
description
Transcript of 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
Syed Maharoof thangal cmahroof917@@gmail.comwww.facebook.com/syed mahrooftwitter.com/syed mahroofin.linkedin.com/in/syed mahroof
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
Char Int Flaot Double void
Types 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
Local Variables
Global variables
Types 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
Here all the variables x , y and z are declared inside the main , so it is local to main() functions
Example
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
Example
A program can have same name for local and global variables
But value of local variables inside a function will take preference
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.
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
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]