Computer Programming (7) - Functions


administrivia

Web Page - http://www.cs.tau.ac.il/~efif/courses/ComputerProgramming


what’s a function?


why use functions?


characteristics of functions


function name


function arguments


function body


return value


function declaration


function declaration vs. definition


what does the function declaration do?


function definition is a declaration


function prototype


an analogy


another analogy


function example


what does this function do?


how might we call this function?


note this


function call expression


function call expression example


function call expression example continued


function call


expression evaluation


return statement


return statement example


function arguments


pass-by-value


let’s review functions


function example


function example – arguments


arguments


function example – return value


return value


function call expression


let’s look at an example


example


Function 1: main()


Function 2: print_heading()


Function 3: print_table()


Function 4: power()


function declaration issues


example


function definition order


example (rearranged)


prototype issues


example


variable declarations


variable concepts


scope


what does this mean?


example – local scope


example – parameter scope


example – global scope


examples

lectures prev top next
Maintained by Efi Fogel. Last modified: November 16 2003.