Tutorial 2: Flowcharts, Modularity,
Numbers
NOTE
In this tutorial we will assume that we are drawing flowcharts by hand on paper. It's better for cementing the concepts/skills because we don't get distracted by learning an application. BUT, there are lots of tools to learn to draw beautiful flowcharts. One that might be in your repertoire (or soon will be) is MIRO
Platform: MIRO
If you are so inclined...
Go to our shared whiteboard here
Exercises
Q1 text2fc
Draw the flowchart: if the light is green, go, otherwise stop.
Q1 text2fc
Draw the flowchart: if the light is green, go, otherwise stop
green?
go
YES
NO
stop
Q2 text2fc
Draw the flowchart: if the light is green, go, otherwise if the light is red, stop.
Q2 text2fc
Draw the flowchart: if the light is green, go, otherwise if the light is red, stop.
green?
red?
go
YES
NO
stop
YES
NO
Click on forward arrow to reveal solution
How to Convert Decimal to Binary (dec2bin)
521 decimal = ? in binary
521 divided by 2 = 260 remainder of 1
260 divided by 2 = 130 remainder of 0
130 divided by 2 = 65 remainder of 0
65 divided by 2 = 32 remainder of 1
32 divided by 2 = 16 remainder of 0
16 divided by 2 = 8 remainder of 0
8 divided by 2 = 4 remainder of 0
4 divided by 2 = 2 remainder of 0
2 divided by 2 = 1 remainder of 0
1 divided by 2 = 0 remainder of 1
Click FORWARD to see step by step computation
How to Convert Decimal to Binary (dec2bin)
521 decimal = ? in binary
521 divided by 2 = 260 remainder of 1
260 divided by 2 = 130 remainder of 0
130 divided by 2 = 65 remainder of 0
65 divided by 2 = 32 remainder of 1
32 divided by 2 = 16 remainder of 0
16 divided by 2 = 8 remainder of 0
8 divided by 2 = 4 remainder of 0
4 divided by 2 = 2 remainder of 0
2 divided by 2 = 1 remainder of 0
1 divided by 2 = 0 remainder of 1
1
0
0
1
1
0
0
0
0
0
How to Convert Decimal to Binary (dec2bin)
521 decimal = ? in binary
1
0
0
1
1
0
0
0
0
0
521 divided by 2 = 260 remainder of 1
260 divided by 2 = 130 remainder of 0
130 divided by 2 = 65 remainder of 0
65 divided by 2 = 32 remainder of 1
32 divided by 2 = 16 remainder of 0
16 divided by 2 = 8 remainder of 0
8 divided by 2 = 4 remainder of 0
4 divided by 2 = 2 remainder of 0
2 divided by 2 = 1 remainder of 0
1 divided by 2 = 0 remainder of 1
Q1021.
Consider this algorithm for converting a number in base 10 to its base 2 representation:
Proceed Stepwise: (1) Pseudocode; (2) Outside; (3) Inside
Divide the number by two recording both the quotient and the remainder.
Write the remainder down
Take the quotient and divide it by two, recording both the quotient and the remainder.
Write the remainder to the LEFT of what's already written.
Repeat until the quotient reaches zero.
Q1021.
Consider this algorithm for converting a number in base 10 to its base 2 representation:
Proceed Stepwise: (1) Pseudocode; (2) Outside; (3) Inside
Divide the number by two recording both the quotient and the remainder.
Write the remainder down
Take the quotient and divide it by two, recording both the quotient and the remainder.
Write the remainder to the LEFT of what's already written.
Repeat until the quotient reaches zero.
N is our number
Q = N / 2
R = remainder
Write R
Treat Q as the new N
If Q not 0, repeat
repeat
Q = N / 2
Write remainder
N = Q
until Q = 0
Q1021.
Consider this algorithm for converting a number in base 10 to its base 2 representation:
Proceed Stepwise: (1) Pseudocode; (2) Outside; (3) Inside
Divide the number by two recording both the quotient and the remainder.
Write the remainder down
Take the quotient and divide it by two, recording both the quotient and the remainder.
Write the remainder to the LEFT of what's already written.
Repeat until the quotient reaches zero.


Fix Filho's Wikipedia Flowchart

Fix Filho's Wikipedia Flowchart



edit if anyone modifies engage in edit war else get on with your life.
make edit repeat engage until agreement

repeat edit page until people stop changing it


edit page if anyone modifies while you don't accept mod repeat discuss until agree make edit
Numbers
Problems
DEC2BIN
BIN2DEC
BIN2HEX
HEX2DEC
ASCII2TEXT
HEX2ASCII2TEXT
What is 43910 in binary?
What is 43910 in binary?
439 / 2 = 219 R1 219 / 2 = 109 R1 109 / 2 = 54 R1 54 / 2 = 27 R0 27 / 2 = 13 R1 13 / 2 = 6 R1 6 / 2 = 3 R0 3 / 2 = 1 R1 1 / 2 = 0 R1
110110111
256+128+32+16+4+2+1=439
What is 11011011012 in decimal?
512+256+64+32+8+4+1=877
What is 3067 in decimal?
3 x 49 + 6 = 153
In what base is 4010written as 28?
To convert 28 base A to decimal we would compute 2 x A + 8 = 40. Solving for A yields 16.
You can be "29" many times in life. What is 29 in these bases?
2913 = ?10
2921 = ?10
2932 = ?10
298 = ?10
2929 = ?10
3510
5110
7310
2510
6710
ASCII
53 74 65 70 77 69 73 65 20 72 65 66 69 6e 65 6d 65 6e 74 20 69 73 20 70 6f 77 65 72 66 75 6c 2e
Use the ASCII table below to decode this message

Stepwise refinement is powerful.
Click for Solution
ASCII
4b 65 65 70 20 43 61 6c 6d 20 61 6e 64 20 44 65 66 65 72 20 44 65 74 61 69 6c 2e
Use the ASCII table below to decode this message

Keep Calm and Defer Detail.
Click for Solution
Use the ASCII to text converter on the next slide to convert the message below:
3c 70 3e 41 6e 73 77 65 72 20 63 6f 72 72 65 63 74 65 64 20 66 6f 72 20 66 69 72 73 74 20 62 6c 61 6e 6b 20 69 6e 20 71 75 65 73 74 69 6f 6e 26 6e 62 73 70 3b 3c 2f 70 3e 0a 3c 70 3e 3c 69 6d 67 20 73 72 63 3d 22 68 74 74 70 73 3a 2f 2f 71 2e 75 74 6f 72 6f 6e 74 6f 2e 63 61 2f 63 6f 75 72 73 65 73 2f 32 32 39 30 31 34 2f 66 69 6c 65 73 2f 31 35 39 37 32 33 31 39 2f 70 72 65 76 69 65 77 22 20 61 6c 74 3d 22 73 63 72 65 65 6e 73 68 6f 74 20 6f 66 20 70 72 6f 62 6c 65 6d 20 73 65 74 20 71 75 65 73 74 69 6f 6e 20 31 31 20 73 68 6f 77 69 6e 67 20 77 68 65 72 65 20 61 6e 73 77 65 72 20 68 61 73 20 62 65 65 6e 20 63 6f 72 72 65 63 74 65 64 22 20 77 69 64 74 68 3d 22 33 32 30 22 20 68 65 69 67 68 74 3d 22 37 32 22 20 2f 3e 3c 2f 70 3e
Use the TEXT2ASCII converter on the next slide to convert the message below:
AD0BE CODE 1CED A BAD 1DEA
You can read all about ASCII at CSUSB and at SparkFun.
Use the URL escape/unescape on the next slide to...
HTTPS%3A//A.COM%3FTITLE%3DWHY%20CAN%27T%20I%20HAVE%20NICE%20THINGS
...decode
https://a.com?title="the title is what i put in quotation marks"
...encode
Binary Coded Decimal (BCD)
See Wikipedia, "Binary Coded Decimal"

Binary Coded Decimal (BCD)
See Wikipedia, "Binary Coded Decimal"
What is the BCD version of
101
7
42
What is the decimal equivalent of these BCD values?
0101
1000 0100
1100
0001 0000 0001
0111
0100 0010
5
84
invalid*
*the unused, don't care-states are named pseudo-tetrad(e)s, pseudo-decimals[ or pseudo-decimal digits. (wikipedia)
The top floors of this skyscraper contain a message. What is it?

OUT TAKES
Example 1
If today is Tuesday, we must be in Belgium

Tuesday?
Belgium
YES
?
Example 2
DO A. IF B, DO C, otherwise DO D. DO E. DO F.
B
A
E
F
C
D
YES
NO
IF B
DO C
OTHERWISE D
IF B,
DO C,
otherwise DO D.
Example 2
DO A. IF B, DO C, otherwise DO D. DO E. DO F.
B
A
E
F
C
D
YES
NO
IF B
DO C
OTHERWISE D
IF B,
DO C,
otherwise DO D.
New Concept: Flowchart for Repetition
WHILE A DO B
A?
B
YES
NO
SINGLE EXIT POINT
SINGLE ENTRY POINT
New Concept: Flowchart for Repetition
REPEAT B UNTIL A
A?
B
SINGLE EXIT POINT
SINGLE ENTRY POINT
NO
YES
Tutorial 2: Flowcharts
By Dan Ryan
Tutorial 2: Flowcharts
- 550