a step-by-step procedure for solving a problem in a finite number of steps
Post on 03-Jan-2016
218 Views
Preview:
TRANSCRIPT
www.btechsmartclass.blogspot.com
Flow Charts & Algorithms
A step-by-step procedure for solving a problem in a finite number of steps.
Algorithm
Problem Statement:
Algorithm Example
Find the sum of natural numbers from 0 to 50
START
IF N <= 50 THEN GOTO Step 4PRINT sumSTOP
Step 1:Step 2:Step 3:Step 4:Step 5:Step 6:Step 7:Step 8:
sum 0N 1sum sum + N N N + 1
Problem Statement:
Algorithm Assignment
Find the sum of any TWO numbers
Problem Statement:Check whether a number given by user is EVEN or ODD
Problem Statement:Find the largest of THREE numbers
Flowchart is a type of diagram that represents an algorithm or process, showing the steps as boxes of various kinds, and their order by connecting them with arrows.
Flow Chart
Terminal Symbol: indicates the starting or stopping point in the logic.
Input/Output Symbol:Represents an input or output process in an algorithm
Process Symbol:Represents any computational step or processing
Decision Symbol:Represents a decision in the logic involving the Comparison Of two values.
Flow Lines
Basic symbols
Basic symbols
www.btechsmartclass.blogspot.com
Three Basic Control Structures
Statemement a
Statemement b
Statemement c
SequenceSequence is a default control structure. Instructions are executed one after another
Selection structure test the condition and then executes one sequence of statements instead of another, depending on whether the condition is true or false
Selection
Condition p?
Statemement a Statemement b
T F
Selection
Condition p?
Statemement a
T
F
Selection
Repetition structure specifies the repetition of an action while some condition remains true. When the conditions of the control statement have been met and control passes to the next statement beyond the repetition structure
Repetition
Condition p?
Statemement block
T
F
Repetition
MAX VALUE1
Print“The largest value is”,
MAX
STOP
Y N
START
InputVALUE1,VALUE2
MAX VALUE2
isVALUE1>VALUE2
Example
Example :largest of three numbers
Assignment questions
1.Check a given number is even or not
2.Display even numbers between 10&100
top related