Professional Documents
Culture Documents
1. Header
2. Dictionary/Declaration
3. Algorithm/Description
Format Syntax Algoritma
HEADER Name/Tittile of Algorithm
Algoritma Hello_world
{ program untuk mencetak “Hello world”}
DEKLARASI
{tidak ada}
DESKRIPSI
Write(“Hello world”)
1 #include <unit_name>
If (terms)
{ action1;
}
else
{ action2;
}
Selection Notation Cont.
Pseudo code C++
6 DEPEND ON <expression> Switch (expression)
<expression 1> : action_1 {
<expression 2> : action_2 case val_1:
………….. : …………… action_1;
<expression n> : action_n break;
or case val_2:
CASE var_name OF action_2;
expconstan 1 : action_1 break;
expconstan 2 : action_2 ……….. : ……….
………………. : …………… case val_n:
expconstan n : action_n action_n;
ELSE other_action break;
ENDCASE default: other_action;
}
Looping Notation
Pseudo code C++
7 [initialisation] [initialisation]
WHILE <terms> DO while (terms)
list_of_action {
{there is an action so that list_of_action;
meet with stop_terms} /*there is an action so that
ENDWHILE meet with stop_terms*/
}
8 [initialisation] [initialisation]
REPEAT do
list_of_action {
{there is an action so that list_of_action;
meet with stop_terms } /*there is an action so that
UNTIL <stop_terms> meet with stop_terms*/
}
while (loop_terms);
Looping Notation Cont.
Pseudo code
9 Var_name TRAVERSAL [start..end]
list_of_action
or
FOR var start TO/DOWNTO end STEP counter DO
list_of_action
ENDFOR
C++
for(start; terms; step)
{
list_of_action;
}
Ex. of Pseudo code
Circle_Area
{calculate the circle area by known radius}
DECLARATION
CONST phi = 3.14
r : integer
Area : real
DESCRIPTION
r5
Area phi * r * r
output(”Radius = ”,r);
output(”Circle area = ”, Area);
Ex. of C++
#include <iostream.h>
#define phi 3.14
main ()
{
int r;
float Area;
r = 5;
Area = phi * r * r;
main ()
{
int r;
float Area;
r = 5;
Area = phi * r * r;
printf(”Radius : %d”,r);
printf(”\nCircle Area : %f”, Area);
}
QUIZ 1
• Create a Pseudo code and a flowchart to find the greatest value from
2 variables. Term : the value of each variable must be typed or manual
input and not initialised in program code.