Functions Are supposed to be fun…. Parameter=Door The word parameter is to function as door is to house. A parameter is used to get data into a function.

Slides:



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

User-Defined Functions Like short programs Can operate on their own data Can receive data from callers and return data to callers.
1 Lecture 16:User-Definded function I Introduction to Computer Science Spring 2006.
Modular Programming With Functions
// Functions that take no arguments #include using namespace std; void function1(); void function2( void ); int main() { function1(); function2(); return.
CPSC230 Computers & Programming I Lecture Notes 20 Function 5 Dr. Ming Zhang.
CS 201 Functions Debzani Deb.
Functions in C. Function Terminology Identifier scope Function declaration, definition, and use Parameters and arguments Parameter order, number, and.
Local Variables A local variable is a variable that is declared within a method declaration. Local variables are accessible only from the method in which.
CHAPTER 7 DATA INPUT OUTPUT Prepared by: Lec. Ghader R. Kurdi.
Functions Modules in C++ are called functions and classes Functions are block of code separated from main() which do a certain task every C++ program must.
Functions CIS Feb-06. Summary Slide Using Functions Mathematical Functions Misc. Functions Naming Conventions Writing Functions –Function Prototype.
USER-DEFINED FUNCTIONS. STANDARD (PREDEFINED) FUNCTIONS  In college algebra a function is defined as a rule or correspondence between values called the.
1 CS161 Introduction to Computer Science Topic #10.
Chapter 4: Subprograms Functions for Problem Solving Mr. Dave Clausen La Cañada High School.
111/15/2015CS150 Introduction to Computer Science 1 Summary  Exam: Friday, October 17,  Assignment: Wednesday, October 15, 2003  We have completed.
COM S 207 Method Instructor: Ying Cai Department of Computer Science Iowa State University
Writing Static Methods Up until now, we have been USING (calling) static methods that other people have written. Now, we will start CREATING our own static.
1 10/18/04CS150 Introduction to Computer Science 1 Functions Divide and Conquer.
Unit 3 Lesson 11 Passing Data and Using Library Functions Textbook Authors: Knowlton, Barksdale, Turner, & Collings PowerPoint Lecture by Dave Clausen.
Chapter 3 Top-Down Design with Functions Part II J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National.
Infsy 307 C++ Powerpoint 1 The Basics. A stream is a flow of characters either “in” or “out” of your program!
Functions: Part 2 of /11/10: Lecture 16 CMSC 104, Section 0101 John Y. Park 1.
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.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming Introduction to simple functions.
CHAPTER 6 USER-DEFINED FUNCTIONS Made By- Kartik Belwal.
Chapter 3 Functions. 2 Overview u 3.2 Using C++ functions  Passing arguments  Header files & libraries u Writing C++ functions  Prototype  Definition.
An Introduction to Programming with C++ Sixth Edition Chapter 10 Void Functions.
CS1201: PROGRAMMING LANGUAGE 2 FUNCTIONS. OVERVIEW What is a Function? Function Prototype Vs Decleration Highlight Some Errors in Function Code Parameters.
Modular Programming – User Defined Functions. CSCE 1062 Outline  Modular programming – user defined functions  Value returning functions  return statement.
Modularity using Functions Chapter 4. Modularity In programming blocks of code often can be "called up" and reused whenever necessary, for example code.
Course Title Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 06 FUNCTIONS 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER) 1.
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Functions (2)
1 ICS103 Programming in C Lecture 8: Functions I.
Functions Structured Programming. Topics to be covered Introduction to Functions Defining a function Calling a function Arguments, local variables and.
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.
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.
1 UMBC CMSC 104, Section Fall 2002 Functions, Part 1 of 3 Topics Top-down Design The Function Concept Using Predefined Functions Programmer-Defined.
User-Defined Functions (cont’d) - Reference Parameters.
Functions in C++ Top Down Design with Functions. Top-down Design Big picture first broken down into smaller pieces.
Functions, Part 1 of 3 Topics  Using Predefined Functions  Programmer-Defined Functions  Using Input Parameters  Function Header Comments Reading 
CS305j Introduction to Computing Parameters and Methods 1 Topic 8 Parameters and Methods "We're flooding people with information. We need to feed it through.
CMSC 104, Section 301, Fall Lecture 18, 11/11/02 Functions, Part 1 of 3 Topics Using Predefined Functions Programmer-Defined Functions Using Input.
 2000 Prentice Hall, Inc. All rights reserved Program Components in C++ Function definitions –Only written once –These statements are hidden from.
Intro. to Computer Programming Eng. Nehal A. Mohamed Spring Semester-2016.
Functions, Part 2 of 2 Topics Functions That Return a Value
Chapter 10: Void Functions
FIGURE 4-10 Function Return Statements
Chapter 7 Top-Down Development
Chapter 5 Functions DDC 2133 Programming II.
Functions in C Mrs. Chitra M. Gaikwad.
CSCI 161: Introduction to Programming Function
Chapter 4: Subprograms Functions for Problem Solving
2008/11/10: Lecture 16 CMSC 104, Section 0101 John Y. Park
FIGURE 4-10 Function Return Statements
2011/11/10: Lecture 21 CMSC 104, Section 4 Richard Chang
4-2 Functions in C In C, the idea of top–down design is done using functions. A C program is made of one or more functions, one and only one of which.
Functions, Part 1 of 3 Topics Using Predefined Functions
Functions, Part 2 of 3 Topics Functions That Return a Value
FIGURE 4-10 Function Return Statements
4-2 Functions in C In C, the idea of top–down design is done using functions. A C program is made of one or more functions, one and only one of which.
Functions Divide and Conquer
Functions, Part 1 of 3 Topics Using Predefined Functions
CS150 Introduction to Computer Science 1
Functions Imran Rashid CTO at ManiWeber Technologies.
FIGURE 4-10 Function Return Statements
Functions, Part 1 of 3 Topics Using Predefined Functions
Functions, Part 2 of 3 Topics Functions That Return a Value
Functions, Part 2 of 42 Topics Functions That Return a Value
Functions, Part 2 of 3 Topics Functions That Return a Value
Presentation transcript:

Functions Are supposed to be fun….

Parameter=Door The word parameter is to function as door is to house. A parameter is used to get data into a function through variables. FUNCTION parameter

Function Declarations A form that contains a r rr return type, function’s name, and parameter declarations. –d–d–d–double cube(int side); These are written before the main programming section and below the includes.

Function Implementation A detailed, complete and executable description of a function. double cube(int side) { return (side*side*side); } These are written after the main programming section.

Parameters A formal parameter is found in the function heading in the implementation section. An actual parameter is when you call the function. The number of arguments in a formal parameter is the same as the actual parameter.

Function declaration For example #include int cube (int side); void main { int theside; cout<<“enter the side of the cube”; cin>> theside; cout<<“The volume of the cube is “<< cube(theside); getch(); } int cube (int side); { return(side*side*side); } Function implementation actual parameter formal parameter Notice the TYPES in the parameters match?

Return Value The function itself can return a value. –Use this if you only have one thing you need from a function. If you need more than one value from a function you can return values using the parameters. –void get_length(int &width, int &length); –use void if you are not returning a value through the function.

Generic Functions The function is used for different things that have the same overall appearance. get_side(“length”); get_side(“width”); Implementation int get_side(apstring name); { int side; cout<<“Please enter the “<<name<< “of your figure.” cin>>side; return(side); }

Assignment Problem number 6 on page 193. All work should be done in functions. The main section should only call the functions. The input files are the 1st 4 digits of the team name there are 3 teams. The names of the teams can be found in team.txt and the output file is bowl.txt. Listen for more instructions. Sample input files will be given. DUE FRIDAY.