Professional Documents
Culture Documents
Learning Outcomes
Explain the concepts of problem-solving and structured
programming.
References:
Problem Solving and Programming Concepts (9 th Edition) . Maureen Sprankle, Jim Hubbard, Pearson Education Limited 2012.
Simple Program Design. A step by step approach (5 th Edition). Lesley Anne Robertson. Cengage Learning 2006.
Contents
6 steps in problem solving1 in everyday Life.
Types of problems1.
Difficulties with problem solving 1
References:
Problem Solving and Programming Concepts (9 th Edition) . Maureen Sprankle, Jim Hubbard, Pearson Education Limited 2012.
Simple Program Design. A step by step approach (5 th Edition). Lesley Anne Robertson. Cengage Learning 2006.
in our life? Step 4: Select the best way to solve the problem
1
1/15/2017
Problem Solving in Everyday Life (cont) Problem Solving in Everyday Life (cont)
Step 1: Identify problem : you are hungry
Lets solve a problem using all 6 steps. Step 2: Understand the problem : you need food
Step 3: Identify Alternatives :
- Method 1: look for mum
- Method 2: go to the kitchen and look for some food
Problem: - Method 3: go to the kitchen and prepare food yourself
You are doing assignment at home, and you are hungry. - Method 4: make a food delivery order
- Method 5: go out to have a meal in a restaurant / hawker center
Problem Solving in Everyday Life (cont) Problem Solving in Everyday Life (cont)
Step 4: Select the best way (based on the alternatives that List out the instruction
you have listed) Go out from the room
- Method 1 : you arent a kid anymore; cant always be looking for mum Go to the kitchen
- Method 2 : it might be a good idea Search the table, cabinet or refrigerator for food
- Method 3 : you might not have the time since you are doing assignment. Consume the food
- Method 4 : it might be expensive to make a delivery order Evaluate the solution
- Method 5 : you might not have the time since you are doing assignment. Does the solution help to solve the problem?
Does the solution solve the problem efficiently?
After some consideration, lets say you choose Method 2 Should we follow the same solution next time?
Types of Problems
Algorithmic solutions
Can be solved with a series of actions (the algorithm)
Hunger solved! Logging on to an e-mail account
Withdrawing cash from ATM machine
Lets move on.
Heuristic solutions (rule of thumb)
(not covered in our syllabus)
Based on knowledge & experience
Requires a process of trial and error
Adding salt to food (during cooking)
Buying the best stock
2
1/15/2017
Introduction to Programming
Computer programming is writing computer
instructions to tell the computer step-by-step how
to process data and carry out other basic operations
systematically3.
Problem solving The basic operations of computers include:
with computers - Receive inputs
- Make decisions
- Repeat operations
- Display results the outputs
References:
3. Computer Science for Matriculation Semester 2. Yew Kwang Hooi, Oxford Fajar 2014.
3
1/15/2017
References:
3. Computer Science for Matriculation Semester 2. Yew Kwang Hooi, Oxford Fajar 2014. References:
3. Computer Science for Matriculation Semester 2. Yew Kwang Hooi, Oxford Fajar 2014.
4
1/15/2017
3 Develop the Outline into an Algorithm 3 Develop the Outline into an Algorithm (cont)
Pseudocode Flowchart
The solution outline developed in Step 2 is expanded Calculate_payment Start
into an algorithm (a set of precise steps that describe Set discount_rate = 0.20
exactly the tasks to be performed and the order in Prompt and Get price discount_rate = 0.20
which they are to be carried out). payment = price price*discount_rate
Prompt and Get price
Develop flow chart and pseudocode from IPO chart. Display payment
END payment = price
price*discount_rate
Display payment
End
5
1/15/2017
C program structure
4 Test the Algorithm for Correctness
#include<stdio.h>
This step is one of the most important in the development
int main(void){ of a program, and yet it is the step most often forgotten.
//printf() is to print output on screen
int a,b; The main purpose of desk checking (test the algorithm) is
to identify major logic errors early, so that they may be
float c;
easily corrected.
a=5;
b=6 ; Early error identification is better because will save time
c=4.23; and cost.
sum=a+b;
printf(Sum is:%f\n,sum);
return 0;
}
4 Test the Algorithm for Correctness (cont) 4 Test the Algorithm for Correctness (cont)
6
1/15/2017
This design process results in the construction of an It can be defined in programming terms as a set of
algorithm. detailed, unambiguous and ordered instructions
developed to describe the process necessary to
produce the desired output from a given input.