05_selection - Selection Control Structure ENCMP 100...

Info icon This preview shows pages 1–14. Sign up to view the full content.

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

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

View Full Document Right 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
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
Image of page 3

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

View Full Document Right 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
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
Image of page 5

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

View Full Document Right 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
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
Image of page 7

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

View Full Document Right 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
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
Image of page 9

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

View Full Document Right 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
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
Image of page 11

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

View Full Document Right 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
Image of page 12
ENCMP 100 13 ©2011 by ECE, UofA Relational Operators cash >= 50 condition operand relational operator operand Selection
Image of page 13

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

View Full Document Right Arrow Icon
Image of page 14
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern