Functions
- We have already seen functions.
- program from chapter 1
- Trace this code.
- int square(int); is the Function Prototype
- Using the function is known as
- invoking the function
- calling the function
- We pass parameters through an argument list.
- Value returning functions return a value.
- Void functions - don't return a value.
- Consider the ftoc.cpp before and
after .
- We are given a set of standard functions. (From page 121)
<cstdlib> | abs(i) | int | int |
<cmath> | cos(x) | float | float |
<cmath> | sin(x) | float | float |
<cmath> | fabs(x) | float | float |
<cmath> | pow(x,y) | float | float |
<cmath> | sqrt(x) | float | float |
- sin and cos operate on angles in radians.
- pow - second argument positive if x=0, x < 0, y must be even.
- sqrt- x must be non negative.