Computer Programming CG
Computer Programming CG
FLOWCHART
DIAGRAM 1
Three tools are used to convert algorithms into
computer programs:
Flowchart - Graphically depicts
the logical steps to carry out a
task and shows how the steps
relate to each other.
Pseudocode - Uses English-like
phrases with some Visual
Basic terms to outline the
program.
2
ALGORITHM
1. Request the number of sheets of paper; call it Sheets.
(input)
2. Divide Sheets by 5. (processing)
3. Round the quotient up to the next highest whole number;
call it Stamps. (processing)
4. Reply with the number Stamps. (output)
3
FLOWCHARTS
Graphically depict the logical
steps to carry out a task and
show how the steps relate to
each other.
4
FLOWCHART SYMBOLS
5
FLOWCHART SYMBOLS CONTINUED
6
FLOWCHART
EXAMPLE
7
STATEMENT STRUCTURES
Sequence – follow instructions
from one line to the next without
skipping over any lines
Decision - if the answer to a
question is “Yes” then one group
of instructions is executed. If the
answer is “No,” then another is
executed
Looping – a series of instructions
are executed over and over
11
SEQUENCE
FLOW CHART
12
DECISION FLOW CHART
13
LOOPING FLOW CHART
14
FLOWCHART
16
FLOWCHART
19
PSEUDOCODE
Program: Determine the average grade of a
class
Initialize Counter and Sum to 0
Do While there are more data
Get the next Grade
Add the Grade to the Sum
Increment the Counter
Loop
Computer Average = Sum / Counter
Display Average
20
TIPS AND TRICKS OF FLOWCHARTS
Flowcharts are time-consuming to write
and difficult to update
For this reason, professional programmers
are more likely to favor pseudocode and
hierarchy charts
Because flowcharts so clearly illustrate
the logical flow of programming
techniques, they are a valuable tool in
the education of programmers
21