P.Lecture - 1.24.08 - Announcements Assignment 1 due...

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

View Full Document Right Arrow Icon
nnouncements Announcements ssignment 1 due tonight Assignment 1 due tonight Blackboard assignment manager ore on Blackboard discussion oard More on Blackboard discussion board getchar() For today: Introduction to algorithm design using flowcharts or pseudocode notation Program control statements (Ch. 5 & 6)
Background image of page 1

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

View Full DocumentRight Arrow Icon
Program control logic • More complex problems require situational decision gic that provides alternative paths of execution: logic that provides alternative paths of execution: 1. Instructions done in sequence (what we have seen so far) can be grouped )g p 2. Selection among alternative paths of execution 3. Iteration/repetition of a set of instructions • C has several types of statements for implementing these capabilities • But first we need to understand these at the program design level
Background image of page 2
Flowchart Symbology 101 Design Primitives Program g start/stop Control flow Process step/ function/ ction Decision Point action Input/output connector These are used to create a flowchart for algorithm design
Background image of page 3

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

View Full DocumentRight Arrow Icon
Three Basic Logic Constructs sequence iteration selection condition T condition F F T . . . one or a block of statements grouped together
Background image of page 4
Three Basic Logic Constructs pseudocode style quence eration lection sequence 1. … iteration 1. Repeat below steps while me ndition true selection 1.If condition is true en 2. … 3…. some condition is true a) b) c) then else end repeat 2. … 3. … end if 2. … 3. … Use indentation to see the block and logic structure
Background image of page 5

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

View Full DocumentRight Arrow Icon
Program Control Statements t lli th fl f th li Controlling the flow of the program’s logic •Selection - deciding among alternative execution aths paths –Boolean values, variables and logical expressions (T/F) • hese are onditions at are tested by your program These are conditions that are tested by your program –Using if and if…else statements –Nested and cascaded if statements –Using switch statements –Conditional Operators - don’t use •Iteration - repetition of statement(s) –Looping idioms: while, do, and for statements –Nested loops –Using break and continue statements
Background image of page 6
Logical Expressions lational tests relational tests The relational operators are: < less than > greater than <= less than or equal >= greater than or equal The value of a relational expression is either 1 (if the condition is ue) or f it is false): true) or 0 (if it is false): 1 < 2 has the value 1 1 > 2 has the value 0 The relational operators have lower precedence than the arithmetic operators. For example: i + j < k 1 means (i + j) < (k 1)
Background image of page 7

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

View Full DocumentRight Arrow Icon
Equality Conditions The equality operators are: == equality != inequality e equality operators produce either 1 or 0 as The equality operators produce either 1 or 0 as their result.
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 31

P.Lecture - 1.24.08 - Announcements Assignment 1 due...

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

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