CSC 253 Lecture 7.

Slides:



Advertisements
Similar presentations
Etter/Ingber Engineering Problem Solving with C Fundamental Concepts Chapter 4 Modular Programming with Functions.
Advertisements

1 Storage Duration and Scope –Local and global variables Storage classes –automatic, static, external, register Todays Material.
Functions and scope Confidence In scope Reference: K&K textbook, Chapter 4.
1 Review of Class on Oct Outline  Pointer  Pointers to void  Call-by-Reference  Basic Scope Rules  Storage Classes  Default Initialization.
CIS 101: Computer Programming and Problem Solving Lecture 9 Usman Roshan Department of Computer Science NJIT.
C Lecture Notes Functions (Cont...). C Lecture Notes 5.8Calling Functions: Call by Value and Call by Reference Used when invoking functions Call by value.
Overview scope - determines when an identifier can be referenced in a program storage class - determines the period of time during which that identifier.
Storage & Linkage: Effects on Scope Rudra Dutta CSC Spring 2007, Section 001.
Storage Classes.
Copyright 2001 Oxford Consulting, Ltd1 January Storage Classes, Scope and Linkage Overview Focus is on the structure of a C++ program with –Multiple.
C Functions Programmer-defined functions – Functions written by the programmer to define specific tasks. Functions are invoked by a function call. The.
18-2 Understand “Scope” of an Identifier Know the Storage Classes of variables and functions Related Chapter: ABC 5.10, 5.11.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. C How To Program - 4th edition Deitels Class 05 University.
18. DECLARATIONS.
1 CSC 110AA Introduction to Computer Science for Majors - Spring 2003 Class 5 Chapter 2 Type Casting, Characters, and Arithmetic Operators.
Object Oriented Programming (OOP) Lecture No. 11.
Lecture 3 Classes, Structs, Enums Passing by reference and value Arrays.
1 Announcements Note from admins: Edit.cshrc.solaris instead of.tcshrc Note from admins: Do not use delta.ece.
 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.
Dale Roberts CSCI 230 Functions Scope, Parameter Passing, Storage Specifiers Department of Computer and Information Science, School of Science, IUPUI Dale.
KIC/Computer Programming & Problem Solving 1.  Header Files  Storage Classes  Scope Rules  Recursion Outline KIC/Computer Programming & Problem Solving.
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MTech[IT],MPhil (Comp.Sci), MCA, MSc[IT], PGDCA, ADCA, Dc. Sc. & Engg.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
Programming Fundamentals. Topics to be covered Today Recursion Inline Functions Scope and Storage Class A simple class Constructor Destructor.
By Anand George SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)
ECE 103 Engineering Programming Chapter 31 C Scopes Herbert G. Mayer, PSU CS Status 8/1/2015 Initial content copied verbatim from ECE 103 material developed.
Review of Function Overloading Allows different functions to have the same name if they have different types or numbers of arguments, e.g. int sqr(int.
1 CSC103: Introduction to Computer and Programming Lecture No 16.
 Static  Example for Static Field  Example for Static Method  Math class methods  Casting  Scope of Declaration  Method Overloading  Constructor.
Chapter 7 - Functions. Functions u Code group that performs single task u Specification refers to what goes into and out of function u Design refers to.
A First Book of ANSI C Fourth Edition
1 This week Basics of functions Stack frames Stack vs. Heap (brief intro) Calling conventions Storage classes vs. scope Library functions Overloading.
C Part 2 Computer Organization I 1 August 2009 © McQuain, Feng & Ribbens The Three Attributes of an Identifier Identifiers have three essential.
Hank Childs, University of Oregon
C Functions -Continue…-.
OBJECT ORIENTED PROGRAMMING
Friend Class Friend Class A friend class can access private and protected members of other class in which it is declared as friend. It is sometimes useful.
ㅎㅎ Fourth step for Learning C++ Programming Namespace Function
COM S 326X Deep C Programming for the 21st Century Prof. Rozier
The Three Attributes of an Identifier
A Lecture for the c++ Course
C-language Lecture By B.S.S.Tejesh, S.Neeraja Asst.Prof.
Command-Line Arguments
Instructor: Ioannis A. Vetsikas
Templates.
Static Data Member and Functions
CSC 253 Lecture 8.
Chapter 5 - Functions Outline 5.1 Introduction
Scope, Parameter Passing, Storage Specifiers
CSC 253 Lecture 8.
Advanced Programming Basics
Name: Rubaisha Rajpoot
Functions: Declaration, Definition, Call and return, Scope of variables, Storage classes, Recursive functions, Recursion vs Iteration.
Variables and Their scope
CSC 253 Lecture 6.
Scoping and Binding of Variables
Storage class.
Namespaces How Shall I Name Thee?.
CISC181 Introduction to Computer Science Dr
How to Do Term Definitions
2. Second Step for Learning C++ Programming • Data Type • Char • Float
CS150 Introduction to Computer Science 1
Programming Language C Language.
In C Programming Language
STORAGE CLASS.
STORAGE CLASS.
CSC 253 Lecture 15.
C Programming Lecture-17 Storage Classes
Templates Generic Programming.
Presentation transcript:

CSC 253 Lecture 7

Storage Classes Of the following storage class modifiers, extern auto register const volatile static which are in some sense “opposites”? which of them are mutually exclusive?

static variables Let’s write a program that demonstrates what a static variable does. What are some uses of static variables?

Let’s try a program with externs Declare int i in one file. Declare int j in another file. Declare one function in each of the two files. What do we need to do to use all the variables and functions from a single main()? What happens if we make them static? Why?

Common errors Let’s write programs demonstrating these … Same name, different type this would occur if you used extern to declare a variable, but then gave it a different type than its original declaration. Multiple different definitions of the same function with external scope.

Variable # of arguments Let’s write a sum function that takes a variable number of arguments.