Chapter 12: Programming in the Large By: Suraya Alias 1-1.

Slides:



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

Introduction to C Programming
Question Bank. Explain the syntax of if else statement? Define Union Define global and local variables with example Concept of recursion with example.
Functions and scope Confidence In scope Reference: K&K textbook, Chapter 4.
Programming Languages and Paradigms
Programming Languages and Paradigms The C Programming Language.
1 Starting a Program The 4 stages that take a C++ program (or any high-level programming language) and execute it in internal memory are: Compiler - C++
Chapter 7: User-Defined Functions II
1 Chapter Three Using Methods. 2 Objectives Learn how to write methods with no arguments and no return value Learn about implementation hiding and how.
Structure of a C program
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 5 - Functions Outline 5.1Introduction 5.2Program.
Run time vs. Compile time
Using Abstraction to Manage Complexity Abstraction: procedural abstraction & data abstraction. Procedural abstraction=> function development should separate.
Functions and Program Structure Chapter 4. Introduction Functions break large computing tasks into smaller ones Appropriate functions hide details of.
CS 201 Functions Debzani Deb.
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Methods of variable creation Global variable –declared very early stage –available at all times from anywhere –created at the start of the program, and.
 2003 Prentice Hall, Inc. All rights reserved. 1 Functions Modules: functions and classes Programs use new and “prepackaged” modules –New: programmer-defined.
1 Run time vs. Compile time The compiler must generate code to handle issues that arise at run time Representation of various data types Procedure linkage.
Chapter 11: Classes and Data Abstraction
1. 2 FUNCTION INLINE FUNCTION DIFFERENCE BETWEEN FUNCTION AND INLINE FUNCTION CONCLUSION 3.
Guide To UNIX Using Linux Third Edition
Introduction to Classes and Objects CS-2303, C-Term Introduction to Classes and Objects CS-2303 System Programming Concepts (Slides include materials.
Overview scope - determines when an identifier can be referenced in a program storage class - determines the period of time during which that identifier.
1 Functions Modules: functions and classes Programs use new and “prepackaged” modules –New: programmer-defined functions, classes –Prepackaged: from the.
1 Classes and Objects. 2 Outlines Class Definitions and Objects Member Functions Data Members –Get and Set functions –Constructors.
C++ for Engineers and Scientists Third Edition
chap13 Chapter 13 Programming in the Large.
Chapter 6: Modularity Using Functions. In this chapter, you will learn about: – Function and parameter declarations – Returning a single value – Returning.
C++ for Engineers and Scientists Second Edition Chapter 6 Modularity Using Functions.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. C How To Program - 4th edition Deitels Class 05 University.
Chapter 6: User-Defined Functions
1 Homework / Exam Finish up K&R Chapters 3 & 4 Starting K&R Chapter 5 Next Class HW4 due next class Go over HW3 solutions.
Chapter 13 Programming in the Large Dr. Jiung-yao Huang Dept. Comm. Eng. Nat. Chung Cheng Univ. TA: 鄭筱親 陳昱豪.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
Chapter 11: Classes and Data Abstraction. C++ Programming: Program Design Including Data Structures, Fourth Edition2 Objectives In this chapter, you will:
© 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 13: Programming in the Large Problem Solving & Program Design.
Fundamentals of C and C++ Programming. EEL 3801 – Lotzi Bölöni Sub-Topics  Basic Program Structure  Variables - Types and Declarations  Basic Program.
Data Structures Using C++ 2E1 Inheritance An “is-a” relationship –Example: “every employee is a person” Allows new class creation from existing classes.
Chapter 5 - Functions Outline 5.1Introduction 5.2Program Modules in C 5.3Math Library Functions 5.4Functions 5.5Function Definitions 5.6Function Prototypes.
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
CPS4200 Unix Systems Programming Chapter 2. Programs, Processes and Threads A program is a prepared sequence of instructions to accomplish a defined task.
1 Announcements Note from admins: Edit.cshrc.solaris instead of.tcshrc Note from admins: Do not use delta.ece.
Chapter 3 Top-Down Design with Functions Part II J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National.
1 CS503: Operating Systems Spring 2014 Part 0: Program Structure Dongyan Xu Department of Computer Science Purdue University.
Chapter 10: Classes and Data Abstraction. Objectives In this chapter, you will: Learn about classes Learn about private, protected, and public members.
Functions Math library functions Function definition Function invocation Argument passing Scope of an variable Programming 1 DCT 1033.
Classes, Interfaces and Packages
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 12: Classes and Data Abstraction.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 11: Classes and Data Abstraction.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 05: Classes and Data Abstraction.
EEL 3801 C++ as an Enhancement of C. EEL 3801 – Lotzi Bölöni Comments  Can be done with // at the start of the commented line.  The end-of-line terminates.
CSci 162 Lecture 8 Martin van Bommel. Large-scale Programming Up to now we have been writing relatively short programs to solve simple problem Want to.
Chapter 10: Classes and Data Abstraction. Classes Object-oriented design (OOD): a problem solving methodology Objects: components of a solution Class:
2Object-Oriented Program Development Using C++ 3 Function Declarations and Definitions Analogize functions to methods –Share same basic features –Unlike.
Functions Chapter 5. Function A set of instructions that are designed to perform specific task. A complete and independent program. It is executed by.
CHAPTER 8 Scope, Lifetime, and More on Functions.
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.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
Unit 10 Code Reuse. Key Concepts Abstraction Header files Implementation files Storage classes Exit function Conditional compilation Command-line arguments.
Lecture 3 Translation.
CISC105 – General Computer Science
Chapter 3: Using Methods, Classes, and Objects
C Short Overview Lembit Jürimägi.
Instructor: Ioannis A. Vetsikas
User-Defined Functions
Chapter 5 - Functions Outline 5.1 Introduction
Programming Languages and Paradigms
C Language B. DHIVYA 17PCA140 II MCA.
Introduction to Classes and Objects
Presentation transcript:

Chapter 12: Programming in the Large By: Suraya Alias 1-1

Figure 13.1 Preparing a Program for Execution 1-2

13.1 Using Abstraction to Manage Complexity Procedural Abstraction – Separation of what a function does from the details of how the function accomplished its purposes. – Example ; fopen(), sqrt() function Data Abstraction – Separation of the logical view of a data object (what is stored) from the physical view (how the information is stored) – Example ; data type double Information hiding – Protecting the implementation details of lower-level module from direct access by a higher-level module – Example ; only access data object through operators Encapsulate – Packaging as a unit a data objects and its operator 1-3

13.2 Personal Libraries : Header Files Header file – Has a.h extension, example header.h – Contains the interface information about a library needed by a compiler to translate a program system – Use the #include preprocessor directive 1-4

Figure 13.2 Header File planet.h for Personal Library with Data Type and Associated Functions 1-5

Figure 13.2 Header File planet.h for Personal Library with Data Type and Associated Functions 1-6

Figure 13.3 Portion of Program That Uses Functions from a Personal Library 1-7

13.2 Personal Libraries : Implementation Files Implementation file – File containing the C source code of a library function and other info – Example; if we create a personal library header.h we can include it in hello.c 1-8

Figure 13.4 Implementation File planet.c Containing Library with Planet Data Type and Operators 1-9

Figure 13.4 Implementation File planet.c Containing Library with Planet Data Type and Operators (cont’d) 1-10

13.4 Storage Classes 1.Auto – Default storage class of function parameters and local variables 2.Extern – Function names are of storage class extern – It will be available to the linker 3.Global variable – A variable that may be accessed by many functions in a program 4.Static – Storage class of variables allocated only once, prior to program execution 5.Register – Storage class of automatic variables that the programmer would like to have stored in register 1-11

Figure 13.5 Storage Classes auto and extern as Previously Seen 1-12

Figure 13.5 Storage Classes auto and extern as Previously Seen (cont’d) 1-13

Figure 13.6 Declaration of a Global Variable 1-14 In eg1.c, the declaration allocates space for global_var_x In eg2.c, the keyword extern allocates no memory. It only informs the compiler

Figure 13.7 Use of Variables of Storage Class extern 1-15

13.5 Modifying Functions for inclusion in a Library The exit() function allows premature termination of program execution The break function can be used to terminate a nested loop 1-16

Figure 13.9 Conditional Compilation of Tracing printf Calls 1-17

13.6 Conditional compilation Figure Conditional Compilation of Tracing printf Calls 1-18

Figure Header File That Protects Itself from Effects of Duplicate Inclusion 1-19

Figure Header File That Protects Itself from Effects of Duplicate Inclusion (cont’d) 1-20

Figure Header File That Protects Itself from Effects of Duplicate Inclusion (cont’d) 1-21

Figure File Backup Using Arguments to Function main 1-22

13.7 Arguments to Function Main Command line arguments 1-23

13.7 Defining Macros with Parameters Macro – Facility for naming a commonly used statement or operation Macro expansion – Process of replacing a macro call by its meaning Use of parentheses Extending macro over two or more lines 1-24

Figure Program Using a Macro with Formal Parameters 1-25

Figure Macro Expansion of Second Macro Call of Program in Fig

Figure Macro Calls Showing Importance of Parentheses in Macro Body 1-27

Figure Macro Calls Showing Importance of Parentheses in Macro Body (cont’d) 1-28

Figure Macro Expansions of Macro Calls from Fig

Chapter 13 – Dynamic data Structures 1-30

Pointers Dynamic data structures – A structure that can expand and contract as a program executes Nodes – Dynamically allocated structures that are linked together to form a composite structure 1-31

Pointers Pointers as function parameters – long_division(40, 3, &quot, &rem) Pointers representing arrays and strings – char *n or char n[] Pointers to structures – An array of structures was represented as a pointer to the first array element Refer table

1-33 Figure 14.1 Comparison of Pointer and Nonpointer Variables

1-34 Figure 14.2 Function with Pointers as Output Parameters