02 Pengantar Algoritma PDF
02 Pengantar Algoritma PDF
Oleh : Muhtadin
Tahapan Pemrograman
Tahapan pemrograman dapat dibagi menjadi dua
fase :
Fase Problem solving
Menghasilkan tahapan terurut yang mendeskripsikan
solusi dari suatu masalah
Tahapan terurut tersebut disebut sebagai algorithm
Fase Implementasi
Mengimplementasikan program kedalam bahasa
pemrograman
Step 1:
Step 2:
Step 3:
Input M1,M2,M3,M4
GRADE (M1+M2+M3+M4)/4
if (GRADE < 50) then
Print FAIL
else
Print PASS
endif
Flowchart
Bahasa : representasi schematic yang merepresentasikan
urutan operasi, sebagai bagian dari proses pembuatan
program komputer.
Symbol Flowchart
Name
Symbol
Use in Flowchart
Oval
Parallelogram
Rectangle
Diamond
Hybrid
Flow line
Contoh Flowchart
START
Step 1:
Step 2:
Step 3:
Input
M1,M2,M3,M4
GRADE(M1+M2+M3+M4)/4
IS
GRADE<50
PRINT
FAIL
PRINT
PASS
STOP
Input M1,M2,M3,M4
GRADE (M1+M2+M3+M4)/4
if (GRADE <50) then
Print FAIL
else
Print PASS
endif
Flowchart
Pseudocode
Pseudocode:
Input the length in feet (Lft)
Calculate the length in cm (Lcm) by
multiplying LFT with 30
Print length in cm (LCM)
Flowchart
START
Input
Lft
Lcm Lft x 30
Print
Lcm
STOP
Contoh
Pseudocode
Pseudocode:
Input the width (W) and Length (L) of a
rectangle
Calculate the area (A) by multiplying L
with W
Print A
Flowchart
START
Input
W, L
ALxW
Print
A
STOP
Flowchart - Decission
Print A
A>B
Print B
Print A
is
A>B
Print B
Operator Relasi
Relational Operators
Operator
Deskripsi
>
Lebih Besar
<
Lebih Kecil
Sama dengan
Contoh
Algoritma
ALGORITMA:
Step 1:
Step 2:
Step 3:
Flowchart
START
Input
VALUE1,VALUE2
is
VALUE1>VALUE2
MAX VALUE1
MAX VALUE2
Print
The largest value is, MAX
STOP
IF - Berulang
Contoh 5: Tuliskan algoritma yang membaca Tiga buah
angka kemudian mencari nilai terbesar dan
mencetaknya pada layar.
Algoritma
Step 1:
Step 2:
Flowchart
Gambarkan Flowchartnya !
Bonus
LEMBUR (2/3)*ABSEN
Bonus Yang
Dibayar
>40 jam
Rp. 50.000
>30 sampai 40 jam
Rp. 40.000
>20 sampai 30 jam
Rp. 30.000
>10 sampai 20 jam
Rp. 20.000
10 jam
Rp. 10.000
Algoritma
Step 1: Input NAMA,LEMBUR,ABSEN
Step 2: if (LEMBUR(2/3)*ABSEN > 40) then
BONUS 50000
else if (LEMBUR(2/3)*ABSEN > 30) then
BONUS 40
else if (LEMBUR(2/3)*ABSEN > 20) then
BONUS 30
else if (LEMBUR(2/3)*ABSEN > 10) then
BONUS 20
else
BONUS 10
endif
Step 3: Print Bonus untuk, NAMA is $, BONUS
Flowchart
Bagaimana Flowchartnya ?
Perulangan
F
Condition p?
T
Statemement block
TERIMA KASIH