CS31-3 - CS 31: Introduction to Computer Science I Topic 3...

Info iconThis preview shows pages 1–13. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 31: Introduction To CS I Topic 3: Functions 1/2010 John A. Rohr All Rights Reserved JAR 3-1 CS 31 : Introduction to Computer Science I Topic 3 Functions
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 31: Introduction To CS I Topic 3: Functions 1/2010 John A. Rohr All Rights Reserved JAR 3-2 Functions Function Definition A function is a single unit of computation Other words for function Procedure Method Subprogram (that returns a value)
Background image of page 2
CS 31: Introduction To CS I Topic 3: Functions 1/2010 John A. Rohr All Rights Reserved JAR 3-3 Functions Function Characterization Accomplishes one thing May use other functions May produce a result Sequence of statements
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 31: Introduction To CS I Topic 3: Functions 1/2010 John A. Rohr All Rights Reserved JAR 3-4 Functions Function Inputs Called “arguments” or “actual parameters” Provides values for calculation Not needed by all functions Display text Generate random number
Background image of page 4
CS 31: Introduction To CS I Topic 3: Functions 1/2010 John A. Rohr All Rights Reserved JAR 3-5 Functions Function Outputs Called the “return value” Reports the results of the processing Not produced by all functions Functions that perform an action only
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 31: Introduction To CS I Topic 3: Functions 1/2010 John A. Rohr All Rights Reserved JAR 3-6 Functions Function Processing Apply defined algorithm Use inputs Generate outputs
Background image of page 6
CS 31: Introduction To CS I Topic 3: Functions 1/2010 John A. Rohr All Rights Reserved JAR 3-7 Functions Function Example Square Root Input: Value: 9 Processing: Calculate square root Output: Square root of value: 3
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 31: Introduction To CS I Topic 3: Functions 1/2010 John A. Rohr All Rights Reserved JAR 3-8 Functions Two Function Dichotomies Function definition dichotomy Predefined functions Programmer-written functions Function return value dichotomy void Typed (int, float, double, char, bool, etc.)
Background image of page 8
CS 31: Introduction To CS I Topic 3: Functions 1/2010 John A. Rohr All Rights Reserved JAR 3-9 Functions Function Definition Types Predefined functions Function library Commercial product Other programmers Programmer defined functions Written by programmer
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 31: Introduction To CS I Topic 3: Functions 1/2010 John A. Rohr All Rights Reserved JAR 3-10 Functions Function Return Value Types Functions that return a value (typed) Perform a calculation (e.g. Square root) Deliver (return) the result Functions that do not return a value (void) Perform an action (e.g. set an output format) Do not have a result to return
Background image of page 10
CS 31: Introduction To CS I Topic 3: Functions 1/2010 John A. Rohr All Rights Reserved JAR 3-11 Functions C++ Predefined Functions Provided by the compiler Organized in libraries Referenced by #include statements Included in program using #include
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 31: Introduction To CS I Topic 3: Functions 1/2010 John A. Rohr All Rights Reserved
Background image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 97

CS31-3 - CS 31: Introduction to Computer Science I Topic 3...

This preview shows document pages 1 - 13. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online