0% found this document useful (0 votes)
0 views21 pages

Problem Solving Methods

The document outlines the fundamentals of programming for problem solving, focusing on algorithms, flowcharts, and pseudocode. It details the steps in the software development lifecycle, the importance of designing algorithms, and provides examples of algorithms for various tasks. Additionally, it explains how to represent algorithms graphically using flowcharts and emphasizes the significance of pseudocode in programming.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views21 pages

Problem Solving Methods

The document outlines the fundamentals of programming for problem solving, focusing on algorithms, flowcharts, and pseudocode. It details the steps in the software development lifecycle, the importance of designing algorithms, and provides examples of algorithms for various tasks. Additionally, it explains how to represent algorithms graphically using flowcharts and emphasizes the significance of pseudocode in programming.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PROGRAMMING FOR

PROBLEM SOLVING --
PPS
SUBJECT CODE-
BTPS-101-18

By
[Link],AP,Chandigarh
Engineering College
UNIT-1

Topic-
Algorithms, Flowchart and Pseudocode

By
[Link],AP,Chandigar
Problem Solving

To solve problem, the steps in software development


lifecycle are:
[Link] Analysis
[Link] Design
[Link] Development
[Link] Documentation and Maintenance

By
[Link],AP,Chandigar
 An algorithm is a set of ordered steps for solving a
problem.
 Examples:
 An algorithm for preparing breakfast.
 An algorithm for converting Gregorian dates to
Islamic dates.
 An algorithm for calculating moon phase.
 An algorithm for drawing a curve.

By [Link],AP,Chandigarh
Engineering College
 Consider the following …
Problem: Prepare a Coffee
How to solve:
1. Start
2. Heat water in a kettle
3. Add coffee powder in a filter
4. Add boiled water to the filter to avail decoction
5. Boil milk
6. Pour required decoction in a cup, add sugar and boiled milk.
7. Enjoy your coffee
8. End

By [Link],AP,Chandigarh Engineering
College
 If we wish to build a house, we need to design it first.
◦ Can you think of some possible consequences of not designing
a house before building it?
 Similarly, computer programs (especially large and
complex ones) need to be designed before they are
written.
◦ Can you think of some possible consequences of not designing
a program before building it?
 One of the things considered when designing a computer
program is the algorithm which it will be based on.

By [Link],AP,Chandigarh Engineering
College
 A computer program is built to solve a certain problem.
Examples:
1. A program to calculate the grade obtained given a
mark.
2. A program to convert a degree into fahrenheit
3. A program to produce a document.

By [Link],AP,Chandigarh Engineering
College
 Below are steps (in fact, an algorithm) for building a
program to solve a particular problem:
◦ Analyse the problem
◦ Design a computer solution to the problem by developing an
algorithm.
◦ Write a computer program based on the algorithm.
◦ Test the program.

By [Link],AP,Chandigarh
Engineering College
 An algorithm must be specific enough so that it can be
conveniently translated into a computer program (using
C, for example).
 An algorithm can be specified:
◦ Textually
For example, using pseudo code
◦ Graphically
For example, using flowcharts or UML activity charts

By [Link],AP,Chandigarh Engineering
College
To find sum of two numbers
 Start the program
 Read two numbers
 Add the two numbers and store in a resultant variable
sum
 Display the sum
 End the program

By [Link],AP,Chandigarh Engineering
College
 A flowchart is a graphical representation of the
sequence of operations in a program.
 An algorithm can be represented graphically using a
flowchart.

By [Link],AP,Chandigarh Engineering
College
Symbol Semantic
Start/End

Process

Input/Output

Test

Connector

Flow of activities
By
[Link],AP,Chandigar
h Engineering College
Start Algorithm starts here

Input
Gregorian date Input data from user

Convert Gregorian
date to Islamic date Perform the date conversion

Display Display the result


Islamic date

End Algorithm ends here


By [Link],AP,Chandigarh Engineering
College
Start
• length, width and
area are referred to
Input
length, width as variables.
• A variable is like a box
in which a value can
area ← length X width be stored

Output
area

End
By [Link],AP,Chandigarh Engineering
College
 Selection Start

Input
height

false true
height > 1.6?

Output Output
“You are short!” “You are tall!”

End
By [Link],AP,Chandigarh Engineering
College
 An outline of a program, written in a form that can
easily be converted into real programming statements. It
resembles the actual program that will be implemented
later. However, it cannot be compiled nor executed.
 Pseudocode normally codes the following actions:
◦ Initialisation of variables
◦ Assignment of values to the variables
◦ Arithmetic operations
◦ Relational operations

By
[Link],AP,Chandigar
h Engineering College
1. Start
2. Read quantity
3. Read price_per_kg
4. price  quantity * price_per_kg
5. Print price
6. End

By
[Link],AP,Chandigar
h Engineering College
 Repetition (looping)
Start

Output
“Thank you!”

Input
stop

false
stop = 1?

true
End By [Link],AP,Chandigarh
Engineering College
 what an algorithm is.
 when an algorithm should be developed when building
a computer program.
 the basic steps in building a computer program to solve
a problem.
 what flowcharts are.
 how to represent algorithms graphically using
flowcharts.

By [Link],AP,Chandigarh
Engineering College
 Write an algorithm, pseudocode and flowchart to find
greatest of three given numbers.

By [Link],AP,Chandigarh
Engineering College
Queries????

You might also like