Function1 documents:
·Functions are like building blocks. They allow complicated programs to be divided into manageable pieces.
·Some of the advantages of functions are:
1. While working on one function, you can focus on just that part of the program and construct it, debug it, and perfect it.
2. Different people can work on different functions simultaneously.
3. If a function is needed in more than one place in a program, or in different programs, you can write it once and use it many times.
•
·Functions are often referred to as modules.
·Functions are like miniature programs. They can be put together to form a larger program.
STANDARD (PREDEFINED) FUNCTIONS
·In college algebra a function is defined as a rule or correspondence between values called the function’s arguments, and the unique value of the function associated with the arguments.
·If f(x) = 2x + 5, then f(1) = 7, f(2) = 9, and f(3) = 11
·1, 2, and 3 are arguments, and 7, 9, and 11 are the corresponding values of the functions.
·
·
·Function in C++
•Pre-defined (standard functions).
•User-defined functions.
Pre-defined Functions
·Some of the pre-defined mathematical functions are abs(x), sqrt(x), and pow(x,y).
·The power function, pow(x,y), calculates xy; that is, the value of pow(x,y) = xy.
·pow(2,3) = 8.0 and pow(2.5,3) = 15.625.
·The function pow is of the type double or that the function pow returns a value of the type double.
·x and y are called the parameters (or arguments) of the function pow.
·Function pow has two parameters.
·The square root function, sqrt(x), calculates the non-negative square root of x for x >= 0.0.
·sqrt(2.25) is 1.5.
·The function sqrt is of the type double and has only one parameter.
·The floor function, floor, calculates the largest whole number that is not greater than x.
·floor(48.79) is 48.0.
·The function floor is of the type double and has only one parameter.
·In C++, pre-defined functions are organized into separate libraries.
·I/O functions are contained in the header file iostream.
·Math functions are contained in the header file cmath.