Relational and Logical Operators Selim Aksoy Bilkent University Department of Computer Engineering

Slides:



Advertisements
Similar presentations
Department of Computer Science. Definition “An operator is a symbol (+,-,*,/) that directs the computer to perform certain mathematical or logical manipulations.
Advertisements

User-defined Functions Selim Aksoy Bilkent University Department of Computer Engineering
Types and Arithmetic Operators
Boolean Algebra Lecture 7: Supporting Material Dr Kathryn Merrick Tuesday 24 th March, 2009.
Lecture 8 Logical Operations Logical functions & Relational operators © 2007 Daniel Valentine. All rights reserved. Published by Elsevier.
Arrays Revisited Selim Aksoy Bilkent University Department of Computer Engineering
Additional Data Types: 2-D Arrays, Logical Arrays, Strings Selim Aksoy Bilkent University Department of Computer Engineering
Branches and Loops Selim Aksoy Bilkent University Department of Computer Engineering
MATLAB Review Selim Aksoy Bilkent University Department of Computer Engineering
Top-down Program Design, Relational and Logical Operators
CS 3850 Lecture 5 Operators. 5.1 Binary Arithmetic Operators Binary arithmetic operators operate on two operands. Register and net (wire) operands are.
Operators. Perl has MANY operators. –Covered in Chapter 3 of Prog.Perl Most operators have numeric and string version –remember Perl will convert variable.
Top-down Program Design Selim Aksoy Bilkent University Department of Computer Engineering
Program Design, Relational and Logical Operators Selim Aksoy Bilkent University Department of Computer Engineering
Fall 2006AE6382 Design Computing1 Relational and Logical Operators Use relational operators to test two values Work with values of true and false Compare.
1 Expressions, Operators Expressions Operators and Precedence Reading for this class: L&L, 2.4.
Additional Data Types: 2-D Arrays, Logical Arrays Selim Aksoy Bilkent University Department of Computer Engineering
Introduction to MATLAB
CSCI 130 Chapter 4 Statements, Expressions, and Operators.
C++ Operators CS242 COMPUTER PROGRAMMING T.Banan Al-Hadlaq.
Ryan Chu. Arithmetic Expressions Arithmetic expressions consist of operators, operands, parentheses, and function calls. The purpose is to specify an.
ORDER OF OPERATIONS x 2 Evaluate the following arithmetic expression: x 2 Each student interpreted the problem differently, resulting in.
Assignment Statements Operator Precedence. ICS111-Java Programming Blanca Polo 2 Assignment, not Equals  An assignment statement changes the value of.
CPS120: Introduction to Computer Science Operations Lecture 9.
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.
What is Matlab Course Goals Precedence Accounts & Login Variables Error Types Course Logistics Vince Bertsch Office:
1 Operators and Expressions. Expressions Combination of Operators and Operands Example 2 * y + 5 Operands Operators.
MM150 Unit 3 Seminar Agenda Seminar Topics Order of Operations Linear Equations in One Variable Formulas Applications of Linear Equations.
1-2 Order of Operations and Evaluating Expressions.
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 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.
MATLAB 及其工程应用 MATLAB and It’s Engineering Application 主讲教师: 胡章芳
By: Mr. Baha Hanene Chapter 6. LEARNING OUTCOMES This chapter will cover the learning outcome 02 i.e. 2.Use basic data-types and input / output in C programs.
Operators & Expressions
Doing math In java.
Copyright © 2014, 2010, and 2006 Pearson Education, Inc. Chapter 1 Introduction to Algebraic Expressions.
Operators.
“Operators” (i.e. “symbols”)
ECE 103 Engineering Programming Chapter 4 Operators Herbert G. Mayer, PSU CS Status 6/19/2015 Initial content copied verbatim from ECE 103 material developed.
STRUCTURED PROGRAMMING C++ Operators. Content 2  C++ operators  Assignment operators  Arithmetic operators  Increment and decrement operators  Decision.
Operators A binary operator combines two values to get one result: x OP y where OP is any binary operators such as +, -, *, /, ==, !=, >, &&, or even =.
LECTURE # 6 : STRUCTURED PROGRAMMING C++ OPERATORS By Mr. Ali Edan.
CSCI 1100/1202 January 18, Arithmetic Expressions An expression is a combination of operators and operands Arithmetic expressions compute numeric.
Logical Expressions ENGR 1181 MATLAB 6. Logical Expressions in Real Life Sorting objects in manufacturing processes can be accomplished automatically.
2.8 Inverse of a Sum on Simplifying continued Goal: to simplify expressions involving parenthesis and to simplify with multiple grouping symbols.
Spreadsheet Calculations Formulas & Functions Computer Applications I.
Rational Expressions relational operators logical operators order of precedence.
LESSON 3 Expressions, Statements, & Operators. STATEMENTS A statement Controls the sequence of execution Evaluates an expression Does nothing (the null.
Principles of Programming - NI July Chapter 4: Basic C Operators In this chapter, you will learn about: Assignment operators Arithmetic operators.
P= Parentheses E= Exponents M= Multiplication D= Division A= Addition S= Subtraction.
CMSC201 Computer Science I for Majors Lecture 03 – Operators
Operators and Expressions
Exponents and Order of Operations
Rational Expressions. relational operators. logical operators
Assignment statement:
A computer program is a sequence of computer commands.
Relational Operators Operator Meaning < Less than > Greater than
Expressions.
Chapter 3: Selection Structures: Making Decisions
Lecture 5 Binary Operation Boolean Logic. Binary Operations Addition Subtraction Multiplication Division.
Lesson 3: Complex Formulas
Spreadsheets Objective 6.02
Chapter 3: Selection Structures: Making Decisions
Number Lines.
Spreadsheets Objective 6.02
Algebra 1 Section 1.8.
Chapter 3: Selection Structures: Making Decisions
A3 4.2a To Operate on Polynomials
ICS 101 Lab 3 Hossain Arif ICS Dept
Primitive Data Types and Operators
Presentation transcript:

Relational and Logical Operators Selim Aksoy Bilkent University Department of Computer Engineering

Summer 2004CS 1112 Relational Operators Relational operators are used to represent conditions (such as “space  0” in the water tank example) Result of the condition is either true or false In MATLAB: false is represented by 0 true is represented by 1 (non-zero)

Summer 2004CS 1113 Relational Operators OperationResult 3 < 41 3 <= 41 3 == 40 3 ~= 41 3 > 40 4 >= 41 ‘A’ < ‘B’1

Summer 2004CS 1114 Relational Operators Don’t confuse equivalance (==) with assignment (=) Be careful about roundoff errors during numeric comparisons (you can represent “x == y” as “abs(x-y) < eps”) Relational operations have lower priority than arithmetic operations (use parentheses to be safe, though)

Summer 2004CS 1115 Logical Operators More complex conditions can be represented by combining relational operations using logic operators Logical operators: &AND |OR xorExclusive OR ~NOT

Summer 2004CS 1116 Logical Operators inputandorxornot aba & ba | bxor(a,b)~a

Summer 2004CS 1117 Operator Hierarchy Processing order of operations: parenthesis (starting from the innermost) exponentials (left to right) multiplications and divisions (left to right) additions and subtractions (left to right) relational operators (left to right) ~ operators & operators (left to right) | operators (left to right)