Problem Solving
Problem Solving
Problem Solving
Problem Solving
• There are 6 steps that you should follow in order to solve a problem:
– 1. Understand the Problem
– 2. Formulate a Model
– 3. Develop an Algorithm
• When problems are straightforward and easy, we can easily find the
solution. But a complex problem requires a methodical approach to find the
right solution. Problem solving begins with the precise
• The first step to solving any problem is to make sure that you understand the
problem that you are trying to solve. we should be absolutely sure about the
objectives of the given problem.
• What format is it in ?
• Is anything missing ?
3. Develop an algorithm
Pseudo codes
These are the instructions written in ordinary English using mathematical and
logical symbols to display the program logic.
Flow Charts
It is a diagrammatic representation of the sequence of operation for a given
problem.
• In this step needs to transform the algorithm into a set of instructions that
can be understood by the computer. Writing a program is often called
"writing code" or “implementing an algorithm”. So the code (or source
code) is actually the program itself.
In this step make sure that it solves the problem that it was intended to solve and
that the solutions are correct.
• It is possible however, that your program works correctly for some set of
data input but not for all.
• If the output of your program is incorrect, it is possible that you did not
convert your algorithm properly into a proper program.
• It is also possible that you did not produce a proper algorithm back in step 3
that handles all situations that could arise.
• Once your program produces a result that seems correct, you need to re-
consider the original problem and make sure that the answer is formatted
into a proper solution to the problem.
Algorithm
Example
of interest.
Step 4: Stop
• The boxes are connected by directional arrows to show the flow of the
solution problem solving.
• The main use of a flowchart is to show the sequence of steps and the
flow of a computer program.
• Terminator
This ellipse symbol represents the beginning and end point in a program. We
use start and stop option in it.
Input/Output Symbol
This parallelogram symbol is used to take any input or output in the
algorithm.
Process Symbol
A rectangle indicates the processing, calculation and arithmetic operations.
Decision Symbol
The diamond is used when we want to take any decision in the program.
These arrows are used to display the flow of the program. It shows the path
of logic flow in a program.
Step 1 : Start
Step 2 : Read a
Step 3 : Read b
Step 4 : Add a , b
Step 5 : Store in d
Step 6 : Print d
Step 7 : End
Selection
• 1. Pre-test loop
Pre-test
Post test
• A post-tested loop executes the body of the loop before testing the
termination condition.