1. Program kelipatan 4
Deklarasi
a: integer
b: integer
ALGORITMA
Read (a)
If (a=4) then
Read (a)
b: a^2 write (kelipatan 4)
else
write (bukan kelipatan 4)
endif
2. Program diskon
Deklarasi
Belanja: integer
Harga sesudah diskon: integer
Harga akhir : integer
Diskon : 15%
Algoritma
Read (belanja)
If (belanja > 100.000) then
Read (belanja)
Harga diskon : total belanja * diskon
Harga akhir : belanja – harga diskon
endif
3. PROGRAM Urutkan
DEKLARASI
a, b, c, max, med, min : integer
ALGORTIMA:
read (a, b, c)
if a > b then
max ← a
else
max ← b
endif
if c > max then
max ← c
endif
if (a > b) and (a < c) or (a < b) and (a > c) then
med ← a
else
if (b > a) and (b < c) or (b < a) and (b > c) then
med ← b
else
med ← c
endif
endif
if a < b then
min ← a
else
min ← b
endif
if c < min then
min ← c
endif
write (min, med, max)
5. Program konversi digit
Deklarasi
a : char
Algoritma
Read (a)
Case a
‘0’ : write (‘0’)
‘1’ : write (‘1’)
‘2’ : write (‘2’)
‘3’ : write (‘3’)
‘4’ : write (‘4’)
‘5’ : write (‘5’)
‘6’ : write (‘6’)
‘7’ : write (‘7’)
‘8’ : write (‘8’)
‘9’ : write (‘9’)
Otherwise : write (‘-99’)
Endcase
7. a. Program angka romawi
Deklarasi
a : integer
Algoritma
Read (a)
Case a
1 : write (‘I’)
2 : write (‘II’)
3 : write (‘III’)
4 : write (‘IV’)
5 : write (‘V’)
6 : write (‘VI’)
7 : write (‘VII’)
8 : write (‘ VII’)
9 : write (‘IX’)
10 : write (‘X’)
Otherwise : write (‘bukan angka romawi’)
endcase