L04_Functions_c++ - Review What prints? cout < enter a...

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

View Full Document Right Arrow Icon
Review s What prints? cout << “enter a value: “; int x=5; double z=0; har ch = ‘ ‘; char ch = ‘ ‘; cin >> x >> z >> ch; cout << “x is: “ << x << endl << “z is: “ << z << endl << “ch is: “ << ch << endl; // 3.14abc
Background image of page 1

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

View Full DocumentRight Arrow Icon
Review s What prints? cout << “enter a value: “; int x=5; double z=0; har h ‘ ‘; char ch = ‘ ‘; cin >> x >> ch >> z; cout << “x is: “ << x << endl << “z is: “ << z << endl << “ch is: “ << ch << endl; // 3.14abc
Background image of page 2
Review s What prints? cout << “enter a value: “; int x=5; double z=0; har h ‘ ‘; char ch = ‘ ‘; cin >> ch >> x >> z; cout << “x is: “ << x << endl << “z is: “ << z << endl << “ch is: “ << ch << endl; // 3.14abc
Background image of page 3

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

View Full DocumentRight Arrow Icon
Today s Functions s concept of fn s fn’s you already know re ritten vs. user efined functions s pre-written vs. user-defined functions s parts of a function
Background image of page 4
What’s a Function input s y = f(x) output s y is unique
Background image of page 5

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

View Full DocumentRight Arrow Icon
Example - algebra input (eval for x = 4) s y = x 2 + 2 * x -1; output (y = 23)
Background image of page 6
To use a fn – just “call” it s “called” by its name s y = 2 + sqrt(25) ; it’s name
Background image of page 7

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

View Full DocumentRight Arrow Icon
What Actually Happens s function call calculate y = 2 + sqrt(25) ; sqrt(25) return the value i t’s 5
Background image of page 8
con’t s using the “returned” value y = 2 + sqrt(25) ; becomes: y = 2 + 5;
Background image of page 9

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

View Full DocumentRight Arrow Icon
Stuff goes in Stuff comes out input (argument) fn call sqrt(25) calculate the value and RETURN it (stuff comes out) { name
Background image of page 10
s
Background image of page 11

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

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/12/2010 for the course EECS 183 taught by Professor Dorf during the Fall '08 term at University of Michigan.

Page1 / 30

L04_Functions_c++ - Review What prints? cout < enter a...

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

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