Kingdom Of Saudi Arabia
Al-Imam University
Faculty of Computer Science and Information
CS140 , Computer programming 1
1st Semester 1435/1436H
Introduction to Problem
Logo suitable for Solving
your presentation
subject T.Tasniem Al-Yahya
AGENDA
Definition
Example: Solving Everyday Problems
Problem solving Process – Computer solution
Summary
AGENDA
Definition
Example: Solving Everyday Problems
Problem solving Process – Computer solution
Summary
Definition
A typical programming task can be divided into two
phases:
Problem solving phase
Produce an ordered sequence of steps that describe solution of
problem
this sequence of steps is called an algorithm
Implementation phase
Implement the program in some programming language
AGENDA
Definition
Example: Solving Everyday Problems
Problem solving Process – Computer solution
Summary
Example:
Solving Everyday Problems
First step in solving a problem: analyze it
E.g., problem of being hungry
Next, you plan, review, implement, evaluate, and
modify (if necessary) the solution
E.g., if you are still hungry
Example:
Solving Everyday Problems (continued)
AGENDA
Definition
Example: Solving Everyday Problems
Problem solving Process – Computer solution
Summary
Problem solving Process – Computer
solution
Problem solving Process – Computer
solution (continued)
Analysis tools ex. IPO charts, pseudocode,
flowcharts
To desk-check or hand-trace, use pencil,
paper, and sample data to walk through
algorithm
A coded algorithm is called a program
Analyzing the Problem
Analyze a problem to:
Determine the goal of solving it
• Output
Determine the items needed to achieve that goal
• Input
Always search first for the output
Analyzing the Problem (continued)
IPO Charts
Use an IPO chart to organize and summarize
the results of a problem analysis
IPO: Input, Processing, and Output
IPO Charts (continued)
IPO Charts (continued)
Analyzing the Problem (continued)
First, reduce the amount of information you need
to consider in your analysis:
Planning the Algorithm
Algorithm: set of instructions that will transform
the problem’s input into its output
Record it in the Processing column of the IPO chart
Processing item: intermediate value used by
algorithm when processing input into output
Pseudocode is a tool programmers use to help
them plan an algorithm
Short English statements
Planning the Algorithm (continued)
Planning the Algorithm (continued)
Flowcharts are also used to plan an algorithm
Use standardized symbols
Symbols connected with flowlines
Oval: start/stop symbol
Rectangle: process symbol
• Represents tasks such as calculations
Parallelogram: input/output symbol
• Represents I/O tasks
Planning the Algorithm (continued)
Planning the Algorithm (continued)
A problem can have more than one solution:
Desk-Checking the Algorithm
An Introduction to Programming with C++, Fifth Edition 22
Desk-Checking the Algorithm
(continued)
Desk-Checking the Algorithm
(continued)
Valid data is data that the programmer is
expecting the user to enter
Invalid data is data that he or she is not
expecting the user to enter
You should test an algorithm with invalid data
Users may make mistakes when entering data
AGENDA
Definition
Example: Solving Everyday Problems
Problem solving Process – Computer solution
Summary
Summary
Problem-solving typically involves analyzing the
problem, and then planning, reviewing,
implementing, evaluating, and modifying (if
necessary) the solution
Programmers use tools (IPO charts, pseudocode,
flowcharts) to help them analyze problems and
develop algorithms
During analysis, you determine the output and input
During planning, you write the steps that will transform the input
into the output
Summary (continued)
After the analysis and planning, you desk-check
the algorithm
Follow each of the steps in algorithm by hand
Coding refers to translating the algorithm into a
language that the computer can understand
Before writing an algorithm, consider whether
you have already solved a similar problem
THE END