Download presentation
Presentation is loading. Please wait.
Published byChristopher Leaverton Modified over 9 years ago
1
Selection Flow Charts If statements
2
Flow of Control The flow of control is a concept we’ve already encountered. The concept of control relates to the machine level in which a single instruction controls the behaviour of the CPU. The flow of control describes how control passes from one instruction to the next.
3
Flow Charts A handy way to map the logic of a program is the Flow Chart. Flow Charts use specific shapes to represent computer actions and join these together with arrows to show the flow of control. Each type of action is represented by a specific shape.
4
Flow Chart Symbols There is no single standard for flow chart shapes, but there is a widely used core set. The start and end of a program are represented by lozenges, ovals or rounded rectangles. The flow of control is represented by arrows. –An arrow coming from one symbol and ending at another symbol represents that control passes in the direction of the arrow.
5
Flow Chart Symbols Processing steps are represented by rectangles. Input/Output are represented by a variety of shapes, including parallelograms. –Some programmers use different symbols for input than for output. –Some even use different symbols for different types of input or output. (printer, screen, speaker, etc.)
6
Charting the Flow of Control Flow charts help visualise the flow of control. The simplest form is sequence. Note the use of alternate symbols for I/O. Declare vars for input and result get input produce result from input show result
7
Flow Chart Symbols Frequently, a program will need alternative logic paths, one for some data, and another for other data. In a flow chart a branch in the logic path is represented by a diamond.
8
Flow Chart Symbols A condition (or decision) is represented by a diamond (rhombus). These typically contain a Yes/No question or True/False test. This symbol is unique in that it has two arrows coming from it: –one corresponding to Yes (or True) –and one corresponding to No (or False).
9
Branches in VB A branch in the logic of a VB program is created by the If statement. If Then … End If
10
If Then If condition Then ‘body End If Condition True False Process
11
If …Then…Else If condition Then ‘body Else ‘body End If Condition TrueFalse Process
12
ElseIf If condition Then ‘body ElseIf condition Then ‘body Else ‘body End If Condition TrueFalse Process Condition TrueFalse Process
13
Else If If condition Then ‘body Else If condition Then ‘body Else ‘body End If Condition TrueFalse Process Condition TrueFalse Process
14
Nested Ifs If condition Then ‘body Else ‘body End If Else If condition Then ‘body Else ‘body End If Condition False Condition True Condition Process False True
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.