0% found this document useful (0 votes)
30 views2 pages

No 6 Using Control

The document describes an algorithm to sort 4 input numbers (3, 1, 2, 5) using control structures. It takes the 4 numbers as input, then uses a series of if/else statements to compare the numbers and determine the sorted order. Based on the comparisons, it will output the numbers in one of the possible sorted orders. The pseudocode walks through the step-by-step logic and comparisons to arrive at the sorted output.

Uploaded by

Annisa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views2 pages

No 6 Using Control

The document describes an algorithm to sort 4 input numbers (3, 1, 2, 5) using control structures. It takes the 4 numbers as input, then uses a series of if/else statements to compare the numbers and determine the sorted order. Based on the comparisons, it will output the numbers in one of the possible sorted orders. The pseudocode walks through the step-by-step logic and comparisons to arrive at the sorted output.

Uploaded by

Annisa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

6. Determine the order of the 4 input numbers (using control strukture)!

Flowchart

Strart

Input a, b, c,
d = 3, 1, 2, 5

a<b
Y Y Output (a, b, c, d)
and b<
a<c c

N Output (a, c, b, d)
b<
N
c

b<a
and Y Y
b<c a< Output (b, a, c,
c d)
N
b< Output (b, c, a, d)
N c

c<b Y Y
b< Output (c, a, b, d)
and
d
c<d
N
Output (c, a, d, b)
b<
N c
Y
a< Output (b, a, c, d)
b
N
b<
Output (a, b, c, d)
c

END
Notasi Algoritma
- Judul : Algoritma mengurutkan empat bilangan = 3, 1, 2, 5 (menggunakan using kontrol)
- Kamus : int = bilangan pertama (a),
bilangan kedua (b),
bilangan ketiga (c),
bilangan ke empat(d)
- Pseudocode :
Input bil (a, b, c, d)
If a<b and a<c
true b<c then
write (‘a, b, c, d’)
false  write (‘ a, c, b, d’) then

else if b<a and b<c


true a<c then
write (‘b, a, c, d’)
false  write (‘b, c, a, d’) then

else if c<a and c<d


true b<d then
write (‘c, a, b, d’)
false  write (‘c, a, d, b’) then

else if a<b then


write (‘b, a, c, d’)
false  write (‘c, a, d, b’) then
else
write (‘a, b, c, d’)
End If
End

You might also like