Chapter2 - Problem Solving Concepts (Programming I)
Chapter2 - Problem Solving Concepts (Programming I)
STIA1113 : Programming I
Lecture Outlines
• Introduction to Problem Solving
• Types of Problems
• Problem Solving with Computers
• Difficulties with Problem Solving
Introduction
• The most important skill for a computer scientist is
problem-solving:
– the ability to formulate problems, think creatively
about solutions, and express a solution clearly and
accurately.
• Programming involves
– problem solving and
– translating the solutions into a computer program
using a programming language (a.k.a . coding)
• A programmer skill: thinking ability to produce the
solution and knowledge about the programming
language
Nature of problem
• A problem in computer science is the statement of
specifications that requires a solution
1 3 5
2 4 6
START
6 Steps in Problem Solving in
Everyday Life
Definitions:
Solution instructions followed to
produce best result (in step 5)
Result outcome, computer-assisted
answer
Program instructions for solution coded
using a computer language
Steps in Building a Program
02 Develop an algorithm.
03 Write the program or coding.
04 Test/ debug the program.
Steps in Building a Program
1. Analyze the problem
Must clearly understand the problem,
The analysis starts by answering these questions:
• What would be considered the input data?
• What would be considered the output information?
• What are the formulas/processes you have to create to solve this
solution?
• Are there any special conditions/constraints?
Steps in Building a Program
2. Develop an algorithm
• Start
– Output "Enter rectangle length: "
– Input length
– Output "Enter rectangle width: "
– Input width
– Calculate perimeter = 2 x(length + width)
– Output perimeter
• End
Flowchart
• a graphical way of depicting a problem in terms of its
inputs, outputs, and processes.
• the basic elements are as follows:
– Rectangle (processing)
– Diamond (decision)
Start
Input length,
width
Perimeter = 2 x
(length + width)
Output
perimeter
Stop