Sunday, 28 August 2011

Pseudo-Codes and Flow Charts


Pseudo-Code

STEP 1: Input X = 1 and Y = 2

STEP 2: Print X

STEP 3: Let X = X + Y

STEP 4: Let Y = Y + 1

STEP 5: If Y < 11, then return to Step 2

STEP 6: Stop

X
Y
PRINT
1
2
1
3
3
3
6
4
6
10
5
10
15
6
15
21
7
21
28
8
28
36
9
36
45
10
45
55
11
55
66
12


Flow Chart

















n
b
Output
n = a
1
10
1
No
2
5
2
No
3
10/3
-
No
4
5/2
-
No
5
2
5
No
6
5/3
-
No
7
10/7
-
No
8
5/4
-
No
9
10/9
-
No
10
1
10
Yes

This shows the multiples of 10.

A specific function can be used to make the algorithm terminate.

©2011 Grant Dwyer

No comments:

Post a Comment