5 Functions IN THIS CHAPTER Assist. Prof. Dr. Ahmed Hashim Mohammed

Slides:



Advertisements
Similar presentations
Macro Processor.
Advertisements

Chapter 14: Overloading and Templates
VBA Modules, Functions, Variables, and Constants
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.
1 The first step in understanding pointers is visualizing what they represent at the machine level. In most modern computers, main memory is divided into.
Chapter 8: Introduction to High-Level Language Programming Invitation to Computer Science, C++ Version, Fourth Edition.
Chapter 9 Introduction to Procedures Dr. Ali Can Takinacı İstanbul Technical University Faculty of Naval Architecture and Ocean Engineering İstanbul -
CS-0401 INTERMEDIATE PROGRAMMING USING JAVA Prof. Dr. Paulo Brasko Ferreira Fall 2014.
CS 2104 Prog. Lang. Concepts Subprograms
Guide to Programming with Python Chapter Six Functions: The Tic-Tac-Toe Game.
CS212: Object Oriented Analysis and Design Lecture 6: Friends, Constructor and destructors.
ITEC 352 Lecture 18 Functions in Assembly. Functions + Assembly Review Questions? Project due on Friday Exam –Average 76 Methods for functions in assembly.
D.L. Patel Institute of management & Technology (M.C.A. College),”Vidyanagri” Name: Bhatt Nishant D. Subject: OOP (object oriented programming language)
Object Oriented Programming Spring COMSATS Institute of Information Technology Functions OOP in C++ by Robert Lafore - Chapter#5 Kaleem Ullah
Copyright © 2012 Pearson Education, Inc. Chapter 13: Introduction to Classes.
Array in C++ / review. An array contains multiple objects of identical types stored sequentially in memory. The individual objects in an array, referred.
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
3. Controlling Program Flow Methods, parameters, and return values Boolean expressions Conditional branching Loops.
Structure Programming Lecture 8 Chapter 5&6 - Function – part I 12 December 2015.
Chapter 4&5 Defining Classes Copyright © 2010 Pearson Addison-Wesley. All rights reserved.
Manish K Parmar PGT (CS) K V VVNagar Thursday, December 24, 2015 Lesson on USER DEFINED FUNCTION IN C++ Presented by Manish K Parmar PGT Computer Science.
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.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 15: Overloading and Templates.
Programming Fundamentals. Topics to be covered Today Recursion Inline Functions Scope and Storage Class A simple class Constructor Destructor.
Programming Fundamentals Enumerations and Functions.
Programming Logic and Design Fifth Edition, Comprehensive Chapter 7 Using Methods.
LECTURE 19 Subroutines and Parameter Passing. ABSTRACTION Recall: Abstraction is the process by which we can hide larger or more complex code fragments.
1 Sections 6.4 – 6.5 Methods and Variables Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Constructors and Destructors
Chapter 9: Value-Returning Functions
Visit for more Learning Resources
Data Type and Function Prepared for CSB210 Pemrograman Berorientasi Objek By Indriani Noor Hapsari, ST, MT Source: study.
Programming with ANSI C ++
Methods Chapter 6.
Functions Review.
GENERAL OOPs CONCEPTS.
Functions and an Introduction to Recursion
UNIT - V STORED PROCEDURE.
Organization of Programming Languages
Introduction to Classes
Chapter 15: Overloading and Templates
Programming Fundamentals
Programmazione I a.a. 2017/2018.
Introduction to Classes
Chapter 4 Functions Objectives
Functions, Procedures, and Abstraction
FUNCTIONS& FUNCTIONS OVERLOADING
Object-Oriented Programming Using C++ Second Edition
Object-Oriented Programming Using C++ Second Edition
Constructors and Other Tools
Dr. Bhargavi Dept of CS CHRIST
Constructors and destructors
Constructors and Destructors
Writing a Complete Program
Functions and an Introduction to Recursion
Chapter8: Statement-Level Control Structures April 9, 2019
Method of Classes Chapter 7, page 155 Lecture /4/6.
The structure of programming
The structure of programming
Prof. Arfaoui. COM390 Chapter 7
Thinking procedurally
Computer Organization and Assembly Language
Object Oriented Programming (OOP)- Assist. Prof. Dr
Functions, Procedures, and Abstraction
C++ Object Oriented 1.
Functions Chapter No. 5.
SPL – PS3 C++ Classes.
Procedures & Macros Introduction Syntax Difference.
Presentation transcript:

5 Functions IN THIS CHAPTER Assist. Prof. Dr. Ahmed Hashim Mohammed • Simple Functions • Passing Arguments to Functions • Returning Values from Functions • Reference Arguments • Overloaded Functions • Recursion • Inline Functions • Default Arguments • Scope and Storage Class • Returning by Reference • const Function Arguments

Simple Functions Functions OOP Functions Dr. Ahmed Hashim Mohammed 1 A function groups a number of program statements into a unit and gives it a name. This unit can then be invoked from other parts of the program. The most important reason to use functions is to aid in the conceptual organization of a pro- gram. Dividing a program into functions is, as we discussed in Chapter 1, “The Big Picture,” one of the major principles of structured programming. (However, object-oriented program- ming provides additional, more powerful ways to organize programs.) Another reason to use functions (and the reason they were invented, long ago) is to reduce pro- gram size. Any sequence of instructions that appears in a program more than once is a candi- date for being made into a function. The function’s code is stored in only one place in memory, even though the function is executed many times in the course of the program. Figure 5.1 shows how a function is invoked from different sections of a program. FIGURE 5.1 Flow of control to a function. Functions in C++ (and C) are similar to subroutines and procedures in various other languages. Simple Functions Our first example demonstrates a simple function whose purpose is to print a line of 45 aster- isks. The example program generates a table, and lines of asterisks are used to make the table more readable. Here’s the listing for TABLE: