Function And Recursion

Function and Recursion

-) Modular Progamming

Program teerdapat di dalam modul

Modul dijadikan sebagai fungsi

Function disebut juga modal

Tujuan Parameter untuk berkomunikasi dengan fungsi lain

Library US user dibagi 2:

-) Libary function

Used definied function

Library function

Example: clrsrc ( ) in conio.h

Sqrt ( ) in math.h

Function definition

Function Construction

Return value type function name ( parameter list )

{

Statements:

}

Contoh parameter

Int maximum ( int x, int y) {

Int max = x;                  ( int harus di atas fungsi main )

If ( y > max ) max; y;

Return max

}

Fungsi prototype

Syntax : return value type function name

( Parameter List );

Int          maximum ( int a; int b; )

Identifier Scoping

Variabel global : bisa pakai semua fungsi

Variabel lokal   : Cuma fungsi di main

 

Recursive Function (2)

-) Base case : return value with out calling next recursive call

-) Reduction step : sequence of input value converging

Leave a Reply

Your email address will not be published. Required fields are marked *