Functions Section 4.3. Last week, we were introduced to procedures Procedures are used in support of top- down program design. –They are used to create.

Slides:



Advertisements
Similar presentations
Getting Input in Python Assumes assignment statement, typecasts.
Advertisements

Subprograms Functions Procedures. Subprograms A subprogram separates the performance of some task from the rest of the program. Benefits: “Divide and.
Tutorial 12: Enhancing Excel with Visual Basic for Applications
1.
Passing Arguments Question Example: IS1102 Exam Autumn 2001.
1 CIS 205 Practice Test George Lamperti A word that has a predefined meaning in a C++ program and cannot be used as a variable name is known as.
Example 2.
1 Executing Method Calls This lecture tells you precisely how method calls are executed (a few details will have to wait until we get to classes and objects).
A Guide to Oracle9i1 Advanced SQL And PL/SQL Topics Chapter 9.
Chapter 9 Modules and Programming with Functions.
Chapter 7: Sub and Function Procedures
Chapter 4 Sec. 4.1, 4.2, 4.4 Procedures (User-defined)
CMSC 104, Version 8/061L18Functions1.ppt Functions, Part 1 of 4 Topics Using Predefined Functions Programmer-Defined Functions Using Input Parameters Function.
Chapter 6 Understanding the Structure of an Application: Procedures, Modules, and Classes.
CHAPTER SIX Reducing Program Complexity General Sub Procedures and Developer-defined Functions.
® Microsoft Access 2010 Tutorial 11 Using and Writing Visual Basic for Applications Code.
Munster Programming Training
CSCI 3327 Visual Basic Chapter 6: Methods: A Deeper Look UTPA – Fall 2011.
Documentation and Comments. What’s a comment? A comment is a simple form of documentation. Documentation is text that you the programmer write to explain.
Sub procedures School of Business Eastern Illinois University © Abdou Illia, Spring 2002 (Week 6, Friday 2/21/03)
Stored procedures1 Stored procedures and functions Procedures and functions stored in the database.
Chapter 9: Writing Procedures Visual Basic.NET Programming: From Problem Analysis to Program Design.
Week 3 Let's review! Fundamental data types List-directed input/output.
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
Data Structures Using C++ 2E1 Inheritance An “is-a” relationship –Example: “every employee is a person” Allows new class creation from existing classes.
Exploring Microsoft Access Chapter 8 Creating More Powerful Applications: Introduction to VBA.
7 1 User-Defined Functions CGI/Perl Programming By Diane Zak.
Chapter 4 - Visual Basic Schneider1 Chapter 4 General Procedures.
CSC 107 – Programming For Science. Today’s Goal  Discuss writing functions that return values  return statement’s meaning and how it works  When and.
PHP. PHP User Defined Functions Besides the built-in PHP functions, we can create our own functions. A function is a block of statements that can be used.
1 Functions, Part 1 of 2 Topics Using Predefined Functions Programmer-Defined Functions Using Input Parameters Function Header Comments.
Chapter 3: Developing Class Methods Object-Oriented Program Development Using Java: A Class-Centered Approach.
User Defined Methods Methods are used to divide complicated programs into manageable pieces. There are predefined methods (methods that are already provided.
4.3 Functions. Functions Last class we talked about the idea and organization of a function. Today we talk about how to program them.
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Managers and “mentors” identified on projects page. All member accounts created and projects populated.
A First Book of ANSI C Fourth Edition Chapter 6 Modularity Using Functions: Part I.
Controlling Program Flow with Decision Structures.
1 UMBC CMSC 104, Section Fall 2002 Functions, Part 1 of 3 Topics Top-down Design The Function Concept Using Predefined Functions Programmer-Defined.
State the domain and range of each relation. Unit 3, Lesson 2 Mrs. King.
Chapter 4 - Visual Basic Schneider1 Chapter 4 General Procedures.
5.2 Relations and Functions. Identifying Relations and Functions Relation: A set of ordered pairs. You can list the set of ordered pairs in a relation.
CMSC 2021 Software Development. CMSC 2022 Software Development Life Cycle Five phases: –Analysis –Design –Implementation –Testing –Maintenance.
Computer Programming Basics Assistant Professor Jeon, Seokhee Assistant Professor Department of Computer Engineering, Kyung Hee University, Korea.
Goal: Identify and graph functions..  Relation: mapping or pairing, of input values with output values.  Domain: Set of input values.  Range: set of.
Invoking methods in the Java library. Jargon: method invocation Terminology: Invoking a method = executing a method Other phrases with exactly the same.
Functions, Part 1 of 3 Topics  Using Predefined Functions  Programmer-Defined Functions  Using Input Parameters  Function Header Comments Reading 
Programming Fundamentals Enumerations and Functions.
CMSC 104, Section 301, Fall Lecture 18, 11/11/02 Functions, Part 1 of 3 Topics Using Predefined Functions Programmer-Defined Functions Using Input.
 The real power of PHP comes from its functions; it has more than 1000 built-in functions.  PHP User Defined Functions  Besides the built-in PHP functions,
Client-side (JavaScript) Validation. Associating a function with a click event – Part 1 Use the input tag’s onclick attribute to associate a function.
Exceptions in the Java programming language J. W. Rider.
 2007 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
IS 350 Application Structure
Functions Chapter 6-Part 2.
Organization of Programming Languages
Think What will be the output?
Chapter 5 Functions DDC 2133 Programming II.
Method.
2011/11/20: Lecture 15 CMSC 104, Section 4 Richard Chang
2008/11/05: Lecture 15 CMSC 104, Section 0101 John Y. Park
© 2016 Pearson Education, Inc.,Hoboken, NJ. All rights reserved.
Functions A function is a “pre-packaged” block of code written to perform a well-defined task Why? Code sharing and reusability Reduces errors Write and.
Functions, Part 1 of 3 Topics Using Predefined Functions
CIS16 Application Development and Programming using Visual Basic.net
Functions, Part 1 of 3 Topics Using Predefined Functions
Brent M. Dingle Texas A&M University Chapter 5 – Section 2-3
Functions, Part 1 of 3 Topics Using Predefined Functions
2008/11/05: Lecture 15 CMSC 104, Section 0101 John Y. Park
Fast-Track UiPath Developer Module 6: Invoke Code and Invoke Method
Functions, Part 1 of 2 Topics Using Predefined Functions
Presentation transcript:

Functions Section 4.3

Last week, we were introduced to procedures Procedures are used in support of top- down program design. –They are used to create modules within our Visual Basic programs.

A typical program design - 1

Now its time for Functions We have already used Visual Basic built-in functions. Now we talk about writing our own user- defined functions. One key conceptual difference between procedures & functions…..

A function always returns exactly value!!!!!!!

Function header : Private Function F_name (parameter_list) Result_type Assigning function result: F_name = result Calling a function: We invoke a function by assigning its result to a variable or by using in an output statement. Arguments & parameters must agree, as with procedures. Note!

Function arguments & parameters Basically, the same rules apply, whether we’re working with procedures or functions, but... None of a function’s parameters should change value within the function execution –if they do, it’s called a side effect (and it’s not good…)

A typical program design - 2 Hierarchy Diagram

Program design In this section of our text, most programs are designed to use procedures & functions as follows: –Input procedure –Output procedure that makes a function call Example: p. 135 #138: use two functions: –findletter(alphabet) –findnumber(num)

In each of the following examples you should have ONE input procedure, and ONE output procedure. The output procedure will CALL A FUNCTION either in the output line or in an assignment. Page 189 # 14 Page 190 # 17