Chapter 05 Flowcharts and Algorithm Updated
Chapter 05 Flowcharts and Algorithm Updated
Course Name:
Information Technology Fundamentals
Chapter 3
Programming Fundamentals
Prepared by:
Dr. Adel Hamdan
Dr. Ahmad Alfraihat
Dr. Moath Altarawneh
Planning Your Solution
• Communication with the Computer
• Organizing the problem
– Flowchart
– Internal and external documentation.
• Using the tools
• Testing the solution
• Coding the solution
2
Communication with the Computer
• Syntax refers to the rules governing the
computer operating system, the language,
and the application.
• An error is called a bug.
3
Organizing the problem
• Flow Chart: Graphic Presentation of the
problem.
4
Algorithms - Definition
• Set of instructions used to complete a task.
• Can be represented as:
5
What is pseudocode
• Pseudocode, like step-form, is a written way of stating algorithms
but uses a much more restricted vocabulary. It is very much like a
3GL and for many programmers and program designers is the
preferred way to state algorithms and program specifications.
• Although there is no standard for pseudocode it is generally quite
easy to read and use, for instance here is some pseudocode:
– DOWHILE kettle_empty
Add_Water_To_Kettle
END DOWHILE
• As you can see it is a precise statement of a while loop.
• Pseudocode is a written statement of an algorithm using a restricted
and well-defined vocabulary. In the next section you look at the
vocabulary in detail.
6
Control Structures
• Bohm & Jacopini showed that all programs
could be written in terms of 3 structures:
7
Flowchart Symbols
• Flow Line
• Start/Stop
• Input/Output
Calculation
• Processing/
Branch Test
• Decision /
8
…Flowchart Symbols
Processing I/O
Decision
9
Example:
Example Algorithm and
Flowchart to enter and print two
variables
10
Internal and External
Documentation
• Internal Documentation:
– Remarks written with the instruction.
• External Documentation:
– Manuals.
11
Testing the solution
• Testing is the process of executing a program with
the deliberate intent of finding errors.
13
Compiling and Running the
program
• Compiling is a process in which the source program
instructions are translated into a form that is
suitable for execution by the computer (object code).
14
…Example 1
15
Example 1 answer
16
…Example 2
• Draw a flowchart and write the steps to
compute the area of a rectangle.
17
Example 2 answer
18
…Example 3
• Draw a flowchart and write the steps to
print “Pass” if the average of 4 numbers is
greater than or equal to 50 or print “Fail”
otherwise.
19
Example 3 answer
20
…Example 4
• Draw a flowchart to find the maximum
number of two numbers.
21
Example 4 answer
22