Chapter 1.0 - Steps in Problem Solving
Chapter 1.0 - Steps in Problem Solving
0
Steps in Problem
Solving
1
1.1 Identifying steps in problem solving
2
a) Describe steps in problem solving : problem
analysis, design a solution, implementation, testing
and documentation
3
Steps in Problem Solving
4
Step 1 : Problem Analysis
5
Step 1 : Problem Analysis
7
Problem Analysis :
Types of Control Structure
Loop / Repetition
Sequence Selection /Iteration
8
Step 2 : Design a Solution
Definition :
An algorithm describes how a problem is solved by
listing the actions that need to be taken and the order
of their execution.
It lists the steps you can follow to solve a problem.
Purpose :
Algorithms can help the programmer plan a
program before writing it in a programming
language.
10
Techniques in Algorithm
11
Pseudocode and Flowchart
Stop
12
Step 3 : Implementation
14
Purpose of Testing
15
Types of Error
syntax errors are easy to find and easy to correct because the
compiler gives indications as to where the errors came from
and why they are wrong.
17
Syntax Error - Example
18
ii) Runtime Error
19
Runtime Error - Example
Example :
i) Input mistakes typically cause runtime errors.
- An input error occurs when the program is waiting for
the user to enter a value, but the user enters a value
that the program cannot handle.
ii) division by zero
- This happens when the divisor is zero for integer
divisions. (eg : 1 / 0)
20
Runtime Error - Example
21
iii) Logic Error
22
Logic Error - Example 1
Example 1:
- Wrong Semicolon at the if Line
23
Logic Error - Example 2
25
Documentation
26
Comment Style
27
Comment Style - Example
28
Documentation - Purpose
29
Quick Test 2
30