Download presentation

Presentation is loading. Please wait.

1
**Lesson 5 - Decision Structure By: Dan Lunney**

Computer Programming 12 Lesson 5 - Decision Structure By: Dan Lunney

2
**If /Then / Else statement**

Decision logic structure is used to make a decision that has 2 outcomes: true or false We test which it is by using the if/then/else statement IF <condition> THEN <True set of instructions> ELSE <False set of instructions>

3
**If/Then/Else Flowchart**

Start IF <condition (s)> TRUE FALSE Instructions if conditions are false Instructions if conditions are true Exit

4
Nested If/Then/Else We can have a second if/then/else statement as the set of instructions for the True and/or False condition of another if/the/else statement This is called a nested if/then/else

5
**Nested If/Then/Else Flowchart**

Start FALSE TRUE if FALSE TRUE if Instructions Instructions Instructions

6
**Three Types of Logic Straight-through (no else part) Positive Logic**

Negative Logic

7
**Straight-Through Logic**

All if statements are executed sequentially There is no ELSE branch to be executed This type of logic is the least efficient because we need to write a code statement for every possible decision

8
**Straight Logic Flowchart**

IF F T IF F T IF F

9
**Positive Logic Most common type as this is how we think**

Continues to processing decisions until a decision is true then it stops executing

10
**Positive Logic Flowchart**

Start TRUE FALSE if TRUE FALSE if Instructions Instructions Instructions Exit

11
**Negative Logic Works the opposite as Positive Logic**

Continues to process decisions until a decision is false then it stops executing

12
**Negative Logic Flowchart**

Start FALSE TRUE if FALSE TRUE if Instructions Instructions Instructions

13
**Sample Problem – Lesson 5**

What would the flowcharts and algorithms of the following problem look like in straight logic, positive logic, and negative logic? People pay $7 for movies if they are under 16, $10 if they are between 16 and 65, and they pay $5 if they are greater than 65. See sample problem sheet

Similar presentations

OK

`. Lecture Overview Structure Programming Basic Control of Structure Programming Selection Logical Operations Iteration Flowchart.

`. Lecture Overview Structure Programming Basic Control of Structure Programming Selection Logical Operations Iteration Flowchart.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on buddhist architecture in india Ppt on swine flu 2015 Ppt on layer 3 switching explained Ppt on describing words for grade 1 Ppt on save child labour Ppt on polynomials of 92 Ppt on brand marketing services Ppt on jewellery management system Time of flight ms ppt online Cell surface display ppt online