J. Michael Moore Logic and Boolean Expressions CSCE 110.

Slides:



Advertisements
Similar presentations
Logic Gates.
Advertisements

Logic Gates.
Computer Systems – Logic Gates Introduce the basic logic gates Introduce truth tables Introduce Boolean algebra (dont panic!) Examples of combining gates.
1 4. Computer Maths and Logic 4.2 Boolean Logic Boolean Operators.
Objectives AND logic OR logic Evaluating compound conditions with multiple logical operators Precedence when combining AND and OR operators Efficiency.
James Tam Making Decisions In Pascal In this section of notes you will learn how to have your Pascal programs choose between alternative courses of action.
Basic Logical Operations (fascinating)
James Tam Making Decisions In Python In this section of notes you will learn how to have your Pascal programs choose between alternative courses of action.
James Tam Making Decisions In Pascal In this section of notes you will learn how to have your Pascal programs choose between alternative courses of action.
James Tam Making Decisions In Pascal In this section of notes you will learn how to have your Pascal programs choose between alternative courses of action.
James Tam Making Decisions In Pascal In this section of notes you will learn how to have your Pascal programs choose between alternative courses of action.
Universal Gates Sum of Products Products of Sum
Boolean Algebra and Logic Gate
Basic Logical Operations (Fascinating)
J. Michael Moore Structured Programming CPSC 110 Drawn from James Tam's material.
J. Michael Moore Other Control Structures CSCE 110 Influenced by material developed by James Tam & Jennifer Welch.
Week 10 Recap CSE 115 Spring For-each loop When we have a collection and want to do something to all elements of that collection we use the for-each.
2-1 Making Decisions Sample assignment statements PayAmount = Hours * Rate PayAmount = 40*Rate + (Hours – 40)*Rate*1.5.
J. Michael Moore Structured Programming CSCE 110 Drawn from James Tam's material.
Programming: Part II In this section of notes you will learn more advanced programming concepts such as branching and repetition as well as how to work.
We will not cover the following sections in class: –7.2 –7.4 –7.8(we will discuss the design topics) You ARE responsible for knowing the topics covered.
J. Michael Moore Other Control Structures CSCE 110 Influenced by material developed by James Tam & Jennifer Welch.
James Tam Making Decisions In Pascal In this section of notes you will learn how to have your Pascal programs choose between alternative courses of action.
CS 3850 Lecture 5 Operators. 5.1 Binary Arithmetic Operators Binary arithmetic operators operate on two operands. Register and net (wire) operands are.
Making Decisions In Python
James Tam Making Decisions In Pascal In this section of notes you will learn how to have your Pascal programs choose between alternative courses of action.
James Tam Making Decisions In Pascal In this section of notes you will learn how to have your Pascal programs choose between alternative courses of action.
Programming Logic and Design Sixth Edition
1 Fundamentals of Computer Science Propositional Logic (Boolean Algebra)
XOR and XNOR Logic Gates. XOR Function Output Y is TRUE if input A OR input B are TRUE Exclusively, else it is FALSE. Logic Symbol  Description  Truth.
Decision II. CSCE 1062 Outline  Boolean expressions  switch statement (section 4.8)
Selection Boolean What is Boolean ? Boolean is a set with only two values : –true –false true and false are standard identifiers in Pascal, called Boolean.
D75P 34R - HNC Computer Architecture Week 6 Boolean Logic © C Nyssen/Aberdeen College 2004 All images © C Nyssen /Aberdeen College unless otherwise stated.
4. Computer Maths and Logic 4.2 Boolean Logic Simplifying Boolean Expressions.
Boolean Logic Logical Operators Comparison Operators Truth tables.
Combinational Logic Design Process © 2014 Project Lead The Way, Inc.Digital Electronics.
Pascal Programming Pascal Loops and Debugging. Pascal Programming Pascal Loops In our first brush with the while do loops, simple comparisons were used.
Programming Perl in UNIX Course Number : CIT 370 Week 3 Prof. Daniel Chen.
Relational and Boolean Operators CSIS 1595: Fundamentals of Programming and Problem Solving 1.
James Tam Making Decisions In Python In this section of notes you will learn how to have your programs choose between alternative courses of action.
Boolean and Sequential Logic Last week – Basic Gates AND OR NOT NOR XOR NAND.
ECOM 4311—Digital System Design with VHDL
James Tam Making Decisions In Python In this section of notes you will learn how to have your programs choose between alternative courses of action.
Department of Electronic & Electrical Engineering Expressions operators operands precedence associativity types.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Yaohang Li.
Pascal Programming George Boole, a 19 th Century mathematician, is created with true, false logic. A Boolean expression in Pascal will be true or false.
Logic Gates and Boolean Algebra Introduction to Logic II.
Logic Gates Learning Objectives Learn that there is a one-to-one relationship between logic gates and Boolean expressions Learn how logic gates are combined.
CPS120 Introduction to Computer Science
Eng. Mai Z. Alyazji October, 2016
Logic Gates.
Logic Gates Benchmark Companies Inc PO Box Aurora CO
Basic Logical Operations (Fascinating)
Digital Signals Digital Signals have two basic states:
CMP 131 Introduction to Computer Programming
2-1 Making Decisions Sample assignment statements
Selection CSCE 121 J. Michael Moore.
Computers & Programming Languages
Scratch: selection / branching/ if / If…else / compound conditionals / error trapping by Mr. Clausen.
Logic Gates.
Chapter 8: More on the Repetition Structure
GCSE Computer Science – Logic Gates & Boolean Expressions
Decision I (if Statement)
Expressions.
Truth tables Mrs. Palmer.
Life is Full of Alternatives
EECE.2160 ECE Application Programming
Flow of Control Flow of control is the order in which a program performs actions. Up to this point, the order has been sequential. A branching statement.
Agenda Lecture Content: Combinatorial Circuits Boolean Algebras
Presentation transcript:

J. Michael Moore Logic and Boolean Expressions CSCE 110

J. Michael Moore Decision-Making With Multiple Expressions Format: if (Boolean-expression) logical-operator (Boolean-expression) then body; Example: if (x > 0) AND (y > 0) then writeln ('X is positive, Y is positive');

J. Michael Moore Decision-Making With Multiple Expressions (2) Built-in logical operators in Pascal OR AND XOR NOT (NAND and NOR can be constructed by combining NOT with AND & NOT with OR)

J. Michael Moore Compound Boolean Expressions With “OR” Operator Format: if (Boolean-expression) OR (Boolean-expression) then body; Example: if (gpa > 3.7) OR (yearsJobExperience > 5) then writeln(‘You are hired’);

J. Michael Moore Compound Boolean Expressions With “AND” Operator Format: if (Boolean-expression) AND (Boolean-expression) then body; Example: if (yearsOnJob <= 2) AND (isGoofOff = True) then writeln(‘You are fired’);

J. Michael Moore Compound Boolean Expressions With “XOR” Operator Format: if (Boolean expression) XOR (Boolean expression) then body; Example: if (takesFirstJob = true) XOR (takesSecondJob = true) then isEmployed := true; OR if (takesFirstJob) XOR (takesSecondJob) then isEmployed := true;

J. Michael Moore Compound Boolean Expressions With “NOT” Operator Format: if NOT (Boolean expression) then body; Examples: if NOT (x AND y) then writeln(‘NAND’); if NOT (x OR y) then writeln(‘NOR’);

J. Michael Moore Order Of The Operations Order/Priority Operator 1 NOT 2 * / DIV MOD AND OR 4 = = <>

J. Michael Moore Why Bracket Boolean Expressions Compound Boolean expressions –e.g., if x > 0 AND y > 0 then AND has highest priority so the ‘0’ and ‘y’ become operands for this operation

J. Michael Moore Range Checking What about doing (x < y < z) to check if y is in the proper range? –Use (x < y) AND (y < z)

J. Michael Moore Quick Summary: Using Multiple Expressions Use multiple expressions when multiple Boolean expressions must be asked and the result of each expression may have an effect on the other expressions: AND: –All Boolean expressions must evaluate to true before the entire expression is true. –If any expression is false then whole expression evaluates to false OR: –If any Boolean expression evaluates to true then the entire expression evaluates to true. –All Boolean expressions must evaluate to false before the entire expression is false.