0% found this document useful (0 votes)
2 views37 pages

Chapter Algorithms and Flow Charts

Uploaded by

amdhepe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views37 pages

Chapter Algorithms and Flow Charts

Uploaded by

amdhepe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 37

PROBLEM SOLVING TECHNIQUES

A typical programming task can be divided


into two phases:
1) Problem solving phase
produce an ordered sequence of steps that
describe solution of problem
this sequence of steps is called an
algorithm
2) Implementation phase
implement the program in some
programming language
ALGORITHM AND FLOW CHART

What is Algorithm?

Algorithm can be defined as: “A sequence


of activities to be processed for getting
desired output from a given input.”
Every algorithm follows a logical flow
(sequence of steps). Generally, the flow is:
1.Start
(Beginning of algorithm)
2.Input
(Read / accept data from user, file, or other
source)
3.Processing
(Perform calculations, apply logic,
comparisons, loops, etc.)
4. Decision Making
(Check conditions → if/else, switch,
loops)
5. Output
(Display or return the result)
6. Stop / End
(Termination of the algorithm)
ALGORITHM EXAMPLES

Write an algorithm to print “Good Morning‟

Step 1: Start
Step 2: Print “Good Morning‟
Step 3: Stop
Add two numbers

•Step 1: Start
•Step 2: Declare variables num1, num2 and sum.
•Step 3: Read values for num1, num2.
•Step 4: Add num1 and num2 and assign the result to
a variable sum.
•Step 5: Display sum
•Step 6: Stop
ALGORITHM EXAMPLES

Write an algorithm to find area of a rectangle.

Step 1: Start
Step 2: Take length and breadth and
store them as L and B?
Step 3: Multiply by L and B and store it
in area
Step 4: Print area
Step 5: Stop
ALGORITHM EXAMPLES

Write an algorithm to check whether he is


eligible to vote? (more than or equal to 18
years old).
Step 1: Start
Step 2: Take age and store it in age
Step 3: Check age value, if age >= 18 then go
to step 4 else step 5
Step 4: Print “Eligible to vote” and go to
step 6
Step 5: Print “Not eligible to vote”
Step 6: Stop
ALGORITHM EXAMPLES

Write an algorithm to check whether given


number is +ve, -ve or zero.

Step 1: Start
Step 2: Take any number and store it in n.
Step 3: Check n value, if n > 0 then go to
step 5 else go to step 4
Step 4: Check n value, if n < 0 then go to
step 6 else go to step 7
ALGORITHM EXAMPLES

Write an algorithm to check whether given


number is +ve, -ve or zero.

Step 5: Print “Given number is +ve”and go


to step 8
Step 6: Print “Given number is -ve” and go
to step 8
Step 7: Print “Given number is zero”
Step 8: Stop
FLOWCHART
FLOWCHART
The flowchart is a diagram which visually pres
ents the flow of data through processing
systems. This means by seeing a flow chart on
e can know the operations performed and
the sequence of these operations in a system
. Algorithms are nothing but sequence of
steps for solving problems. So a flow chart ca
n be used for representing an algorithm. A
flowchart, will describe the operations
(and in what sequence) are required
to solve a given problem.
FLOWCHART
A flowchart is a type of diagram that
represents an algorithm, workflow or
process. The flowchart shows the steps as
boxes of various kinds, and their order by
connecting the boxes with arrows. This
diagrammatic representation illustrates a
solution model to a given problem.
Flowcharts are used in analyzing,
designing, documenting or managing a
process or program in various fields.
BUILDING BLOCKS
OF
FLOW CHART
OR
COMMON SYMBOLS
OF
FLOW CHART
BUILDING BLOCKS OF FLOW CHART

ANSI/ISO
Name Description
Shape
Shows the process's order of
operation. A line coming from
one symbol and pointing at
Flowline
another. Arrowheads are
(Arrowhead)
added if the flow is not the
standard top-to-bottom, left-
to right.
BUILDING BLOCKS OF FLOW CHART

ANSI/ISO
Name Description
Shape
Indicates the beginning and ending
of a program or sub-process.
Represented as a stadium, oval or
rounded (fillet) rectangle. They
Terminal usually contain the word "Start" or
"End", or another phrase signaling
the start or end of a process, such as
"submit inquiry" or "receive
product".
BUILDING BLOCKS OF FLOW CHART

ANSI/ISO
Name Description
Shape
Represents a set of operations that
Process changes value, form, or location of
data. Represented as a rectangle
BUILDING BLOCKS OF FLOW CHART

ANSI/ISO
Name Description
Shape
Shows a conditional operation that
determines which one of the two
paths the program will take. The
Decision operation is commonly a yes/no
question or true/false test.
Represented as a diamond
(rhombus).
BUILDING BLOCKS OF FLOW CHART

ANSI/ISO
Name Description
Shape
Indicates the process of inputting
Input / and outputting data, as in entering
Output data or displaying results.
Represented as a parallelogram
Add two numbers
FLOWCHART EXAMPLES
Draw a flowchart to find the simple interest.
(Sequence)
FLOWCHART EXAMPLES
Draw a flowchart to find bigger number
among two numbers (selective)
FLOWCHART EXAMPLES

Draw a flow chart to find factorial of any


number.
FLOWCHART EXAMPLES
FLOWCHART EXAMPLES

Draw a flow chart to print the number from 1


to N.
FLOWCHART EXAMPLES
FLOWCHART EXAMPLES

Draw a flow chart to find biggest number


among N numbers.
FLOWCHART EXAMPLES
CLASS TEST
MULTIPLE CHOICE QUESTIONS
Time: 40 Min Max Marks 20
1. A step by step method for solving a problem
using English Language

(a) program (b) Flowchart


(c) statement (d) Algorithm

2. Set of statements is executed based upon


conditional test.

(a) Looping (b) Selective


(c) Sequence (d) None
MULTIPLE CHOICE QUESTIONS

3. Set of statements is executed again and again


based upon conditional test.
(a) Looping (b) Selective
(c) Sequence (d) None

4. The graphical representation of algorithm is


(a) program (b) Flowchart
(c) statement (d) Algorithm

5. All instructions are executed one after other.


(a) Looping (b) Selective
(c) Sequence (d) None
ANSWER THE FOLLOWING QUESTIONS.

1. Define Algorithm.

2. Define Flowchart.

3. Write an algorithm to find the sum of two


numbers.

4. Write an algorithm to find the area of a


triangle.

5. Write an algorithm to find whether given


number is odd or even.
ANSWER THE FOLLOWING QUESTIONS.

6. Write an algorithm to find the sum of all even


number up to given number.

7. Draw a flowchart to find the area of a circle.

9. Draw a flowchart to find the smallest number


among n numbers.
ANSWER THE FOLLOWING QUESTIONS.

10. Draw a flowchart to find the sum of all


multiples of 5 up to given number.

11. Mona is confused about finite loop and


infinite loop, explain her with the help of
example.

12. Write an algorithm and a flowchart to find


sum of n numbers.
THANK YOU

You might also like