Operators Operators are symbols such as + (addition), - (subtraction), and * (multiplication). Operators do something with values. $foo = 25; $foo – 15;

Slides:



Advertisements
Similar presentations
Session 1 & 2BBK P1 Module5-May-2007 : [‹#›] PHP: Moving On..
Advertisements

Operators and Expressions Operators are symbols that produce a result based on some rules. Examples: +, -, =, > and
Conditionals – if - else Dr. Sajib Datta
Chapter 2: Java Fundamentals Operators. Introduction to OOP Dr. S. GANNOUNI & Dr. A. TOUIR Page 2 Content Group of Operators Arithmetic Operators Assignment.
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.
1 Expressions, Operators Expressions Operators and Precedence Reading for this class: L&L, 2.4.
Java Primitives The Smallest Building Blocks of the Language (corresponds with Chapter 2)
Exercises A-Declare a variable of double type with initial value=0.0; B- Declare a constant of String type with initial value=“Good” C- Declare a variable.
2440: 211 Interactive Web Programming Expressions & Operators.
Basic Operators. What is an operator? using expression is equal to 9. Here, 4 and 5 are called operands and + is the operator Python language supports.
CONTROL STRUCTURE The if, elseif, and else & switch Statements 1.
CompSci 100E 2.1 Java Basics - Expressions  Literals  A literal is a constant value also called a self-defining term  Possibilities: o Object: null,
Operators. Today’s Learning Goals … Understand the purpose of JavaScript operators Explore the mathematical operators Find out about the assignment operators.
Lesson - 7. Operators There are three types of operators: Arithmetic Operators Relational and Equality Operators Logical Operators.
C Operators. CONTENTS C OPERATORS TYPES OF OPERATOR UNARY BINARY TERNARY ARITHMATIC RELATIONAL LOGICAL.
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.
PHY-102 SAPVariables and OperatorsSlide 1 Variables and Operators In this section we will learn how about variables in Java and basic operations one can.
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.
Assignment and Arithmetic Operators.
Principles of Programming Chapter 4: Basic C Operators  In this chapter, you will learn about:  Arithmetic operators  Unary operators  Binary operators.
Arithmetic Expressions Addition (+) Subtraction (-) Multiplication (*) Division (/) –Integer –Real Number Mod Operator (%) Same as regular Depends on the.
Module 5 JavaScript Operators. CS346 Javascript-52 Examples  JS-5 Examples.
Chapter Two Operators and Expressions Lesson Seven.
Doing math In java.
CSM-Java Programming-I Spring,2005 Fundamental Data Types Lesson - 2.
OperatorstMyn1 Operators An operator is something that you feed with one or more values (or expressions, in programming jargon) which yields another value.
FP512 WEB PROGRAMMING 1 PREPARED BY: PN. NUR SYUHADA BINTI MOHAMAD.
 Arithmetic Operator :  Increment / Decrement Operator :  Assignment Operator :  Comparision Operator :  Logical Operator :  Ternary Operator : 
Operators.
“Operators” (i.e. “symbols”)
What are Operators? Some useful operators to get you started.
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.
CSCI 1100/1202 January 18, Arithmetic Expressions An expression is a combination of operators and operands Arithmetic expressions compute numeric.
CHAPTER 2 PART #4 OPERATOR 1 st semester King Saud University College of Applied studies and Community Service Csc
Operators Chapter 4 - Lecture Slides Math, Conditional operators, conversions They aren’t all just objects to me, some of them are primitive.
Principles of Programming - NI July Chapter 4: Basic C Operators In this chapter, you will learn about: Assignment operators Arithmetic operators.
ECE 103 Engineering Programming Chapter 4 Operators Herbert G. Mayer, PSU Status 6/10/2016 Initial content copied verbatim from ECE 103 material developed.
Chapter 3 Math Operations. Objectives Use the assignment and arithmetic operators. Use operators in output statements. Explain the problem with division.
CompSci 230 S Programming Techniques
>> Fundamental Concepts in PHP
Expressions.
CHAPTER 5 SERVER SIDE SCRIPTING
Expressions.
University of Central Florida COP 3330 Object Oriented Programming
2.0 FUNDAMENTALS OF JAVA PROGRAMMING LANGUAGE
Overview: Programming Concepts
University of Central Florida COP 3330 Object Oriented Programming
Assignment statement:
Relational Operations
By: Muhammad Zidny Naf’an
Operators and Expressions
Arithmetic Operator Operation Example + addition x + y
With Assignment Operator
PHP: Basics FdSc Module 109 Server side scripting and Database design
C Operators, Operands, Expressions & Statements
JavaScript Part 2.
Introduction to Programming – 4 Operators
Alternate Version of STARTING OUT WITH C++ 4th Edition
Chapter 2: Java Fundamentals
Data Types and Expressions
Operators In Java Programming By Rajanikanth B.
Chapter 4: Expression and Operator
OPERATORS AND EXPRESSIONS IN C++
Operator and Expression
Operator King Saud University
Algoritma & Pemrograman 1
Data Types and Expressions
COMPUTING.
Data Types and Expressions
Presentation transcript:

Operators Operators are symbols such as + (addition), - (subtraction), and * (multiplication). Operators do something with values. $foo = 25; $foo – 15; // $foo and 15 are the operands, - is the operator

Arithmetic Operators + Addition $a + $b - Subtraction $a - $b * Multiplication $a * $b / Division $a / $b % Modulus (modulus divides the first value by the second, and returns the remainder e.g. $foo = 9; echo ($foo % 4); // 1 )

Assignment Operators Assignment operators set the value of variables = Assignment $a = $b copies $b's value into $a =& Reference $a =& $b set $a to reference $b

Concatenation Operator Concatenation means to put things together. The concatenation operator puts strings together. . Concatenation appends 2nd value to 1st $first = "Barack"; $second = "Obama" Echo ($first . " " . $second); // Barack Obama

Comparison Operators == Equals true if $a = $b === Identical true if $a = $b and of same type $x = 50; // integer $y = "50"; // string if ($x == $y) { echo "$x is the same as $y"; } // 50 is the same as 50

$x = 50; // integer $y = "50"; // string if ($x === $y) { echo "$x is the same as $y"; } else { echo "$x is not the same as $y"; } // 50 is not the same as 50

Comparison Operators != Not Equal true if $a is not equal to $b !== Not Identical true if $a is not identical to $b < Less Than true if $a is less than $b > Greater Than true if $a is greater than $b <= Less Than or Equal to >= Greater Than or Equal to

Increment/Decrement Operators ++$a pre-increment increments $a by 1, then returns $a $a++ post-increment returns $a, then increments $a by 1 --$a pre-decrement decrements $a by 1, $a-- post-decrement returns $a, then decrements by 1

$a = 10; echo $a++ . "<br />"; echo $a; // 10 11 echo ++$a; // 11

Logical Operators AND true if both $a AND $b are true $a = 10; $b = 5; if ($a > 5 AND $b >= 5) { echo "This is pretty cool"; } // This is pretty cool && is the same as AND

Logical Operators OR true if either $a AND $b are true $a = 10; $b = 5; if ($a > 5 OR $b > 5) { echo "This is pretty cool"; } // This is pretty cool || is the same as OR