A flowchart is a diagram that depicts the “flow” of a program.
•
The figure shown here is a flowchart for the addition of two numbers.
START Display message “Please enter two numbers” Read two Numbers Calculate the Sum
Display Sum END Nihar Ranjan Roy
2
Basic Flowchart Symbols •
Notice there are three types of symbols in i n this flowchart: –
rounded rectangles parallelograms a rectangle Each symbol represents a different type of operation. –
–
•
Symbol Symbol
Name ovals or rounded rectangles (terminals)
M Meaning eaning Start or end of a process
Arrows
Flow of control
parallelograms Rectangle
Input/output Processing (indicates a process such as a mathematical computation or variable assignment )
Nihar Ranjan Roy
3
Flow of control in flow chart START
Please enter two numbers
Output operation
Display message “Please enter two numbers”
Read two Numbers Calculate the Sum
Display Sum END
Nihar Ranjan Roy
4
Flow of control in flow chart START
Please enter two numbers 12
Display message “Please enter two numbers”
13
Read operation
Read two Numbers Calculate the Sum
Accept the value and store them into variables Fno Sno
Display Sum END
Nihar Ranjan Roy
5
Flow of control in flow chart START
Please enter two 12
numbers 13
Display message “Please enter two numbers”
Read two Numbers
Processing /calculation Processing/calculate
Calculate the Sum
Display Sum
Sum=Fno+Sno END
Nihar Ranjan Roy
6
Flow of control in flow chart START
Please enter two 12
numbers 13
Display message “Please enter two numbers”
25
Read two Numbers Calculate the Sum
Output
Display Sum END
Nihar Ranjan Roy
7
Four Flowchart Structures Sequence Decision Repetition Case
• • • •
Nihar Ranjan Roy
8
Sequence Structure •
•
A series of actions are performed in sequence The addition of two numbers was a sequential activity
Nihar Ranjan Roy
9
Decision Structure •
•
One of two possible actions is taken, depending on a condition. A new symbol, the diamond, indicates a yes/no question. If the answer to the question is yes, the flow follows one path. If the answer is no, the flow follows another path –
–
NO
Nihar Ranjan Roy
YES
10
PROBLEM
Accept two numbers and find the square of
Nihar Ranjan Roy
11
Decision Structure •
In the flowchart segment below, the question “is x < y?” is asked. If the answer then process A is performed. If the answer is yes, then processisB no, is performed.
Thank you for interesting in our services. We are a non-profit group that run this website to share documents. We need your help to maintenance this website.