lecture6 - 1 Janice Regan, CMPT 128, Jan 2007 CMPT 128:...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 Janice Regan, CMPT 128, Jan 2007 CMPT 128: Introduction to Computing Science for Engineering Students Logical and Relational Expressions and Logical and Relational Operators Janice Regan, CMPT 128, Jan 2007 2 Control Structures Three methods of processing a program In sequence Branching Looping Branch: Altering the flow of program execution by making a selection or choice Loop: Altering the flow of program execution by repetition of a particular block of statement(s) Janice Regan, CMPT 128, Jan 2007 3 Selection Based on Branching One-Way Selection One alternative: Things to do if a condition is true C++ implementation: if statement Two-Way Selection Two alternatives: Things to do if the condition is true, a different things to do if the condition is false C++ implementation: if-else statement Janice Regan, CMPT 128, Jan 2007 4 Selection Based on Branching Multiple Selections A series of different sets of things to do. Choose which set based on which of a series of conditions hold C++ implementation: if-elseif-else structure Alternate C++ implementation: Nested if statements Switch Structures A series of different things to do depending on the value of a particular variable Janice Regan, CMPT 128, Jan 2007 5 Decisions Use a decision statement when an action is to be taken only if or while a particular condition holds The condition which must hold may be logical or relational expression or a Boolean variable. The value of the condition must be True or False Each possible path through a condition statement will contain a sequence of steps to be executed The condition and the sequences of steps that are executed for each outcome of the condition statement form a selection structure ....
View Full Document

This note was uploaded on 05/18/2010 for the course CMPT 128 taught by Professor Regan during the Spring '08 term at Simon Fraser.

Page1 / 29

lecture6 - 1 Janice Regan, CMPT 128, Jan 2007 CMPT 128:...

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

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