CS161_Topic#6

CS161_Topic#6 - CS161 CS161 Introduction to Computer...

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

View Full Document Right Arrow Icon
1 CS161 CS161 Introduction to Introduction to Computer Science Computer Science Topic #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
CS161 Topic #6 2 Today in CS161 More Selective Execution Logical Operations: && and || Truth Tables Applying logicals to if statements Operator Precedence Increment and Decrement Operators
Background image of page 2
CS161 Topic #6 3 Logical Operators There are 3 logical (boolean) operators: And (operates on two operands) || Or (operates on two operands) ! Not (operates on a single operand) && evaluates to true if both of its operands are true; otherwise it is false.
Background image of page 3

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

View Full DocumentRight Arrow Icon
CS161 Topic #6 4 Logical Operators || evaluates to true if one or the other of its operands are true; it evaluates to false only if both of its operands are false. ! gives the boolean complement of the operand. If the operand was true, it results in false.
Background image of page 4
CS161 Topic #6 5 Logical Operators Conditional Expression Logical value True/False (5 == 10) && (30 < 88) 0 False (5 == 10) || (30 < 88) 1 True 1 True 40 != 44 1 True !(40 != 44) 0 False
Background image of page 5

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

View Full DocumentRight Arrow Icon
CS161 Topic #6 6 Expressions in C++ Every expression in C++ results in a value For example, when you call the pow function, it results in a value that consisted of raising exp to the power supplied. This value can then be used within a larger expression, eg: x = y + pow(x,3); This value is called the residual value
Background image of page 6
CS161 Topic #6 7 AND Truth Table
Background image of page 7

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

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

This note was uploaded on 03/17/2010 for the course CS 161 taught by Professor Fant during the Winter '08 term at Portland State.

Page1 / 23

CS161_Topic#6 - CS161 CS161 Introduction to Computer...

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

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