Local Variables, Global Variables and Variable Scope

Slides:



Advertisements
Similar presentations
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Advertisements

C++ Statements represent the lowest-level building blocks of a program and it may be like:. A simple statement is a computation terminated by a semicolon.
Data Structures (Second Part) Lecture 2 : Pointers Bong-Soo Sohn Assistant Professor School of Computer Science and Engineering Chung-Ang University.
Chapter 8 Scope, Lifetime and More on Functions. Definitions Scope –The region of program code where it is legal to reference (use) an identifier Three.
Informática II Prof. Dr. Gustavo Patiño MJ
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 13P. 1Winter Quarter Scope of Variables.
Liang Chapter 6 Variable scope and the keyword this.
1 Modularity In “C”. 2 General Syntax data_type function_Name (parameter list) { … return expression; // return output } Body of the function is a compound.
1 Pointers, Dynamic Data, and Reference Types Review on Pointers Reference Variables Dynamic Memory Allocation –The new operator –The delete operator –Dynamic.
Overview scope - determines when an identifier can be referenced in a program storage class - determines the period of time during which that identifier.
Storage Classes.
MAHENDRAN CHAPTER 6. Session Objectives Explain Type of Functions Discuss category of Functions Declaration & Prototypes Explain User Defined Functions.
1 CS 192 Lecture 5 Winter 2003 December 10-11, 2003 Dr. Shafay Shamail.
PASSING VALUE TO A FUNCTION # CALL BY VALUECALL BY VALUE # CALL BY REFERENCECALL BY REFERENCE STORAGE CLASS # AUTOAUTO # EXTERNALEXTERNAL # STATICSTATIC.
Defining and Converting Data Copyright Kip Irvine, 2003 Last Update: 11/4/2003.
Data Types. Data types Data type tells the type of data, that you are going to store in memory. It gives the information to compiler that how much memory.
18. DECLARATIONS.
Chapter 9 Pointers and Dynamic Arrays (9.1). Pointers A variables which holds the memory address for a variable of a specific type. Call-by-Reference.
Object Oriented Programming (OOP) Lecture No. 11.
CSC241 Object-Oriented Programming (OOP) Lecture No. 6.
CSC241 Object-Oriented Programming (OOP) Lecture No. 4.
 2007 Pearson Education, Inc. All rights reserved Random Number Generation  rand function – Load – Returns "random" number between
C++ Programming Lecture 11 Functions – Part III By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
C++ / G4MICE Course Session 2 Basic C++ types. Control and Looping Functions in C Function/method signatures and scope.
In Java.... Variables contain the values of primitive data types Value Types.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 12P. 1Winter Quarter User-Written Functions Lecture 12.
Functions in C CSE 2451 Rong Shi. Functions Why use functions? – Reusability Same operation, different data – Abstraction Only need to know how to call.
1 CSC103: Introduction to Computer and Programming Lecture No 24.
System Programming Practical Session 7 C++ Memory Handling.
CMSC 202 Computer Science II for Majors. CMSC 202UMBC Topics Memory management operators Dynamic memory Project 2 questions.
Data Types Always data types will decide which type of information we are storing into variables In C programming language we are having 3 types of basic.
Chapter 2. Variable and Data type
Department of Electronic & Electrical Engineering Functions Parameters Arguments Pointers/dereference & * Scope Global/Local Storage Static/Automatic.
 constant represented by a name, just like a variable, but whose value cannot be changed  The const keyword precedes the type, name, and initialization.
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
C syntax (simplified) BNF. Program ::= [ ] Directives ::= [ ] ::= | |… ::=#include > ::=#define.
Dynamic memory allocation and Intraprogram Communication.
Introduction to Programming
Eine By: Avinash Reddy 09/29/2016.
User Interaction and Variables
Introduction to Programming
trigraph ??= is for # ??( is for [ ??< is for { ??! is for |
Anatomy of a class Part I
Pointer Basics Psst… over there.
Advanced Programming Basics
CS 240 – Lecture 5 Scope of Variables, The Stack, Automatic Variables, Global Variables, Constant Type.
Programming -2 برمجة -2 المحاضرة-7 Lecture-7.
Value Types and Reference Types
Introduction to Programming
Storage class.
Default Arguments.
Object oriented programming (OOP) Lecture No. 7
Dynamic Memory.
C Programming Lecture-8 Pointers and Memory Management
C Programming Lecture-13 Structures
C Programming Pointers
C Data Types and Variable
Pointer Basics Psst… over there.
C Programming Lecture-14 Unions
Object Oriented Programming (OOP) Lecture No. 11
STORAGE CLASS.
STORAGE CLASS.
CSCE 206 Lab Structured Programming in C
C Programming Lecture-3 Keywords, Datatypes, Constants & Variables
Pointers, Dynamic Data, and Reference Types
CS148 Introduction to Programming II
C Programming Lecture-17 Storage Classes
Anatomy of a class Part I
Object Oriented Programming (OOP) Lecture No. 12
Scope Rules.
Presentation transcript:

Local Variables, Global Variables and Variable Scope $p!derLabWeb C Programming Lecture-10 Local Variables, Global Variables and Variable Scope

Local Variables The variables which are declared inside the function or in a block is called the local variables. Its scope is inside that block or function. Which means that they can’t be accessed outside that block or function. When these are declared and not initialized with some value then these are initialized with the garbage values.

Global Variables These are the variables whose scope is all over the program. Which means we can access them any where in the program. When these are declared and not initialized with some value then these are initialized with the default values.

Default Values Table Datatype Default Values int float char ‘\0’ float char ‘\0’ double Pointer NULL

Thank you!