CS161_Topic#6

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

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

1 CS161 CS161 Introduction to Introduction to Computer Science Computer Science Topic #6

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

View Full Document
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
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.

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

View Full Document
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.
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

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

View Full Document
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
CS161 Topic #6 7 AND Truth Table

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

View Full Document
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
Ask a homework question - tutors are online