On the same day with the Cloud Computing Seminar in the Auditorium of BINUS Anggrek, we learned about function and recursion.
FUNCTION
Are also called : Sub-program, where we group some statements to do a particular job.There are some advantages of using modular programming or using function:
1. Can be done by more than one programmer
2. Easier to debug and modification will not affect the whole program.
3. Easier to be documented.
the syntax of function is:
return-value-type function_name(parameter_lists){
statements;
}
There are 2 types of function, one that returns value to the main function, and the other one who doesn't, called void function.
There are 2 ways to pass a parameter/parameters:
1. By Value : we pass the value of the variables.
2. By Reference : we are using pointer, to point at certain variables that we need.
RECURSION
Recursion function is a function that calls itself.In recursion we have to define 2 things: Base case and the Reduction steps. Base case shows the simplest function that has to be done.
There are some case examples that use Recursion, for example to accumulate certain numbers, Fibonacci sequences, finding binary numbers, etc.
No comments:
Post a Comment