Chapter 51 Logical Operators Used with Boolean expressions Not – makes a False expression True and vice versa And – will yield a True if and only if both.

Slides:



Advertisements
Similar presentations
Chapter 2 Flow of Control. Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 2-2 Learning Objectives Boolean Expressions Building, Evaluating.
Advertisements

Types and Arithmetic Operators
Conditional statements and Boolean expressions. The if-statement in Java (1) The if-statement is a conditional statement The statement is executed only.
Chapter 5 - VB.Net by Schneider
Chapter 31 Fundamentals of Programming in VB(Continue I) Numbers Arithmetic Operations Variables Incrementing the Value of a Variable.
Fall 2006AE6382 Design Computing1 Relational and Logical Operators Use relational operators to test two values Work with values of true and false Compare.
Chapter 3 Math Vocabulary
C++ Operators CS242 COMPUTER PROGRAMMING T.Banan Al-Hadlaq.
Computer Science 101 The Boolean System. George Boole British mathematician ( ) Boolean algebra –Logic –Set theory –Circuits –Conditions in if.
2440: 211 Interactive Web Programming Expressions & Operators.
Chapter 5 – Decisions 5.1 Relational and Logical Operators 5.2 If Blocks 5.3 Select Case Blocks.
ORDER OF OPERATIONS x 2 Evaluate the following arithmetic expression: x 2 Each student interpreted the problem differently, resulting in.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Chapter 4 - VB 2008 by Schneider1 Chapter 4 – Decisions 4.1 Relational and Logical Operators 4.2 If Blocks 4.3 Select Case Blocks.
Chapter 5 - VB 2005 by Schneider1 Chapter 5 – Decisions 5.1 Relational and Logical Operators 5.2 If Blocks 5.3 Select Case Blocks 5.4 A Case Study: Weekly.
CSCI 3328 Object Oriented Programming in C# Chapter 5: C# Control Statement – Part II UTPA – Fall
CS31: Introduction to Computer Science I Discussion 1A 4/9/2010 Sungwon Yang
Chapter 5 Decisions. Outline and Objectives Relational and Logical Operators If Blocks Select Case Blocks.
Chapter 5 - VB 2005 by Schneider1 Chapter 5 – Decisions 5.1 Relational and Logical Operators 5.2 If Blocks.
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 1B) UTPA – Fall 2011.
CPS120: Introduction to Computer Science Operations Lecture 9.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
Numbers continued The Integer Data Type Multiple Declarations Parentheses Three Types of Errors.
Operators Precedence - Operators with the highest precedence will be executed first. Page 54 of the book and Appendix B list C's operator precedence. Parenthesis.
© ABB University - 1 Revision C E x t e n d e d A u t o m a t i o n S y s t e m x A Chapter 11 Structured Text Course T314.
Boolean Logic Logical Operators Comparison Operators Truth tables.
Data Types Declarations Expressions Data storage C++ Basics.
Assignment statement: Assigns a value to a variable Variable must appear on the left side, value on the right side of the assignment operator Right side.
Chapter 51 Decisions Relational and Logical Operators If Blocks Select Case Blocks.
Conditional Statements © Copyright 2014, Fred McClurg All Rights Reserved.
Relational and Boolean Operators CSIS 1595: Fundamentals of Programming and Problem Solving 1.
1.6. DEFINITIONS  An equation is a statement that two expressions are equal.  Usually contains 1 or more variables  A variable is a symbol that represents.
Data And Variables Chapter Names vs. Values Michael Jordan name (the letter sequence used to refer to something) value (the thing itself)
1 Chapter 4 – Decisions 4.1 Relational and Logical Operators 4.2 If Blocks 4.3 Select Case Blocks 4.4 Input via User Selection.
Condition Testing. Condition testing is a test case design method that exercises the logical conditions contained in a program module. A simple condition.
“Operators” (i.e. “symbols”)
Chapter 6 - Repetition. while Loop u Simplest loop u Two parts: test expression and loop body u Pre-tested loop –Execute loop body if test true –Bypass.
CHAPTER FOUR Performing Calculations and Manipulating Data: Expressions.
Chapter 3 - VB 2008 by Schneider1 Chapter 3 – Variables, Input, and Output 3.1 Numbers 3.2 Strings 3.3 Input and Output.
Chapter 4 - VB 2008 by Schneider1 Chapter 4 – Decisions 4.1 Relational and Logical Operators 4.2 If Blocks 4.3 Select Case Blocks.
1 Chapter 5 – Decisions 5.1 Relational and Logical Operators 5.2 If Blocks 5.3 Select Case Blocks 5.4 A Case Study: Weekly Payroll.
Week 4 Relational and Logical Operators Dr. Jennifer Cunningham.
1Object-Oriented Program Development Using C++ Built-in Data Types Data type –Range of values –Set of operations on those values Literal: refers to acceptable.
Visual Basic Variables
Sequence, Selection, Iteration The IF Statement
Chapter 4 - VB 2008 by Schneider
Condition Testing.
Addition/ Subtraction
Assignment statement:
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
Chapter 4 – Decisions 4.1 Relational and Logical Operators
For what number is 23 x 32 x 7 the prime factorization?
Computers & Programming Languages
البرمجة بلغة الفيجول بيسك ستوديو
Chapter 8 JavaScript: Control Statements, Part 2
Numbers.
Computer Science 210 Computer Organization
Unit 1: Day 3 – 1 and 2 step equations
Chapter 8: More on the Repetition Structure
Core Objects, Variables, Input, and Output
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
Lecture 5 Binary Operation Boolean Logic. Binary Operations Addition Subtraction Multiplication Division.
Chapter 5 Decisions.
Section 6.1 Order of Operations
The Selection Structure
Section 6.1 Order of Operations
Multiply and divide Expressions
DATA TYPES AND OPERATIONS
Evaluating Expressions
Introduction to Python
Presentation transcript:

Chapter 51 Logical Operators Used with Boolean expressions Not – makes a False expression True and vice versa And – will yield a True if and only if both expressions are True Or – will yield a True if at least one of both expressions are True

Chapter 52 Example To test if n falls between 2 and 5: (2 < n ) And ( n < 5 )

Chapter 53 Syntax error The following is NOT a correct way to test if n falls between 2 and 5: (2 < n < 5 )

Chapter 54 Example n = 4, answ = “Y” Are the following expressions true or false? Not (n < 6) (answ = "Y") Or (answ = "y") (answ = "Y") And (answ = "y") Not(answ = "y")

Chapter 55 Order of Operations The order of operations for evaluating Boolean expressions is: 1.Arithmetic operators 2.Relational operators 3.Logical operators

Chapter 56 Arithmetic Order of Operations 1.Parenthesis 2.Exponentiation 3.Division and multiplication 4.Addition and subtraction

Chapter 57 Relational Order of Operations They all have the same precedence

Chapter 58 Logical Order of Operations 1. Not 2. And 3. Or

Chapter 59 Condition A condition is an expression involving relational and/or logical operators Result of the condition is Boolean – that is, True or False

Chapter 510 Common Error in Boolean Expressions A common error is to replace the condition Not ( 2 < 3 ) by the condition ( 2 > 3 ) The correct replacement is ( 2 >= 3 ) because >= is the opposite of

Chapter 511 Boolean Variable A variable declared with a statement of the form Dim var As Boolean is said to have Boolean data type. It can assume just the two values True and False. Example: Dim boolVar As Boolean boolVar = 2 < 6 txtBox.Text = boolVar displays True in the text box.