I. Summary
1.Function
In C, It represent a module by a function.A function may receive data and may return a value.
The description of the internal logic of a function as the function's definition
2. function definition
A function definition consists of a header and a body.
The body is the code block that contains the module instructions and generates the return value.
The header, which precedes the body, includes the module name and the list of parameters that receive the module data enclosed within parentheses.
3. syntax of a function definition
II. Practice
1 .int power(int m, int n) – In: m, n; Out: mn
2.int gt(int n) – In: n; Out: n!
use :
n ! = n*(n-1)*(n-2)*.....*2*1.
3.double expx(double x, double epsi) – In: x, epsi; Out: ex with precision < epsi
use: e^x = 1 + x/1! + x^2/2! + ... + x^n/n!
4.double sinx(double x, double epsi) – In: x, epsi; Out: sin(x) with precision < epsi
use:
sin(x) = x x^3/3! + x^5/5! + ... + (1)^n*x^(2n+1)/(2n+1)!
5.double pi(double epsi) – In: epsi; Out: PI number with precision < epsi
use: pi = 4*( 1 -1/3+1/5-1/7+....)
6.int highest(double epsi) – In: epsi; Out: Highest n so that 1/n >= epsi
7.int highest1(double epsi) – In: epsi; Out: Highest n so that 1/n! >= epsi
9. Check n divided 5
10. calculate sum
III. Total
I know function, i know use function,
I know function is very convenient, we don't must code again. if we need repeat.
we are easy to find problem .