05_selection - Selection Control Structure ENCMP 100...

Info iconThis preview shows pages 1–13. Sign up to view the full content.

View Full Document Right Arrow Icon
Selection Control Structure
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ENCMP 100 2 ©2011 by ECE, UofA Overview Programming structures Relational and logical operators Selection statements construct if construct switch/case construct try/catch construct menu Flowchart and pseudo-code Logic function: find Selection
Background image of page 2
ENCMP 100 3 ©2011 by ECE, UofA Programming Structures - Introduction The programs we have looked at so far are fairly limited they will always perform the same series of instructions, in the same order they cannot make decisions about whether or not a particular action(s) needs to be performed they can calculate results via expressions, but cannot use those results to effect what they do We need to see how to add logic and control structures to our programs to overcome these limitations Selection
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ENCMP 100 4 ©2011 by ECE, UofA Programming Structures - Program Flow The normal flow of program control is sequential . The sequential flow of control can be altered in precisely defined ways using control structures for selection repetition invocation Any program can be written with just these four control flows nearly every programming language supports these control structures Selection
Background image of page 4
ENCMP 100 5 ©2011 by ECE, UofA Programming Structures sequence: a list of commands executed one after another, they are executed in the order in which they are placed within the program sequence selection repetition  (loop) invocation Selection
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ENCMP 100 6 ©2011 by ECE, UofA Programming Structures selection: execution of one set of comments if some criterion is true, or other set if the criterion is false sequence selection repetition  (loop) invocation Selection
Background image of page 6
ENCMP 100 7 ©2011 by ECE, UofA Programming Structures repetition: a group of statements is executed multiple times sequence selection repetition  (loop) invocation Selection
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ENCMP 100 8 ©2011 by ECE, UofA Programming Structures invocation: a group of statements can be invoked (by a call) at any place in the program – function (we cover it later) sequence selection repetition  (loop) invocation Selection
Background image of page 8
ENCMP 100 9 ©2011 by ECE, UofA Programming Structures The selection and repetition structures depend on relational and logical operators. They are used to determine what commands should be executed which path for the case of selection should the loop continue for the case of repetition Selection
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ENCMP 100 10 ©2011 by ECE, UofA Relational and Logical Operators Control structures depend on relational and logical operators – they require comparisons (conditions) Relational operators make comparisons Logical operators allow us to combine the comparisons Selection
Background image of page 10
ENCMP 100 11 ©2011 by ECE, UofA Relational Operators operator interpretation < less than <= less than or equal to > greater than >= greater than or equal to == equal to ~= not equal to Selection
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ENCMP 100 12 ©2011 by ECE, UofA Relational Operators the result of comparison is either true or false most computer programs use the number 1 for true and 0 for false Selection
Background image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/27/2011 for the course ENCMP 100 taught by Professor Cockburn during the Spring '11 term at University of Alberta.

Page1 / 74

05_selection - Selection Control Structure ENCMP 100...

This preview shows document pages 1 - 13. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online