<<< Iteration (for loop) | Index | Functions, cont. >>> |
What was square( i ) ?
It was call of the function named square()
int square( int x ) { return x * x; }
We define a function when we want to separate a computation because it
is logically separate
makes the program text clearer (by naming the computation)
is useful in more than one place in our program
eases testing, distribution of labor, and maintenance
<<< Iteration (for loop) | Index | Functions, cont. >>> |