Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 18

Object Oriented Programming

Unit-I
Problem Solving
Problem Solving
• A Computer is a very powerful machine
capable of performing a multitude of different
tasks
• Responsibility on the user to instruct the
computer in a correct and precise manner, so
that the machine is able to perform the
required job in a proper way
Problem Solving
• In order to instruct a computer correctly, the
user must have clear understanding of the
problem to be solved.

• Develop a method, in the form of series of


sequential steps, to solve a given problem.
Problem Solving
• A Computer cannot solve a problem on its
own. One has to provide step by step
instructions to the computer. In fact, the task
of problem solving is not that of the computer.
It is the programmer who has to write down
the solution to the problem in terms of simple
operations which the computer can
understand and execute.
Problem Solving
• Steps involved
1. Understanding the problem
2. Analyzing the problem
3. Developing the solution

4. Coding and implementation


Algorithm
In general
Set of sequential steps usually written in Ordinary
Language to solve a given problem is called Algorithm.
More technical
An algorithm can be defined as “a complete,
unambiguous, finite number of logical steps for solving a
specific problem “
An algorithm can be written in English like sentences or in
any standard representation sometimes, algorithm
written in English like languages are called Pseudo Code
Algorithm development
• Step1. Identification of input:
– The input is to be indentified first for any specified problem.

• Step2: Identification of output:


– The output to produced/expected

• Step3 : Identification the processing operations :


– The steps to be performed in order to lead to output from the given input
• Step4 : Processing Definiteness :
– The instructions composing the algorithm must be clear and there should
not be any ambiguity in them
Algorithm Development
• Step5 : Processing Finiteness :
– If go through the algorithm, then for all cases, the
algorithm should terminate after a finite number
of steps.
• Step6 : Possessing Effectiveness :
– The instructions in the algorithm must be
sufficiently basic and in practice they can be
carries out easily.
Algorithm Development
An algorithm must possess the following properties
1. Finiteness: An algorithm must terminate in a finite number of
steps
2. Definiteness: Each step of the algorithm must be precisely and
unambiguously stated
3. Effectiveness: Each step must be effective, should be easily
convertible into program statement
4. Generality: The algorithm must be complete in itself so that it can
be used to solve problems of a specific type for any input data.
5. Input/output: Each algorithm must take zero, one or more
quantities as input data produce one or more output values.
Algorithm Develoment
Example 1. find the average of three numbers,
the algorithm is as follows
• Step 1 Read the numbers a, b, c
• Step 2 Compute the sum of a, b and c
• Step 3 Divide the sum by 3
• Step 4 Store the result in variable d
• Step 5 Print the value of d Step 6 End of the
program
Exercise
1. Write an algorithm to calculate the simple
interest using the formula. Simple interest =
P*N* R/100.
2. Write an algorithm to find the area of the
triangle
3. Write an algorithm to find the largest of three
numbers X, Y,Z.
4. Write down an algorithm to find the largest data
value of a set of given data values
Flowchart
• A flow chart is a step by step diagrammatic
representation of the logic paths to solve a
given problem.

• A flowchart is visual or graphical


representation of an algorithm.
Flowchart
• A flow chart is a step by step diagrammatic
representation of the logic paths to solve a
given problem.

• A flowchart is visual or graphical


representation of an algorithm.
Flowchart
Advantages of Flowcharts
1. The flowchart shows the logic of a problem displayed in
pictorial fashion helps in easier checking of an algorithm.
2. The Flowchart is good means of communication to other
users. It is also a compact means of recording an
algorithmic solution to a problem.
3. The flowchart allows the problem solver to break the
problem into parts. These parts can be connected to make
master chart.
4. The flowchart is a permanent record of the solution which
can be consulted at a later time.
Symbols in Flowchart
Symbols in Flowchart
Symbols in Flowchart

You might also like