Operators Flashcards
assignment operator
(=) assigns a value to a variable Ex: Assignment var x = 10;
addition operator
(+) adds numbers Ex: Adding var x = 5; var y = 2; var z = x + y;
multiplication operator
(*) multiplies numbers Ex: Multiplying var x = 5; var y = 2; var z = x * y;
+
Addition
-
Subtraction
*
Multiplication
/
Division
%
Modulus
++
Increment
–
Decrement
=
Ex: x = y
Same As:
x = y
+=
EX: x += y
Same As:
x = x + y
-=
Ex: x -= y
Same As:
x = x - y
*=
Ex: x *= y
Same As:
x = x * y
/=
Ex: x /= y
Same As:
x = x / y
%=
Ex: x %= y
Same As:
x = x % y
addition assignment operator
(+=) adds a value to a variable
what can the + be used for?
also be used to add (concatenate) strings Example txt1 = "John"; txt2 = "Doe"; txt3 = txt1 + " " + txt2;
+= assignment operator
also be used to add (concatenate) strings
When used on strings the + operator is called ?
concatenation operator
Can you add strings and numbers together?
Yes, Adding two numbers, will return the sum, but adding a number and a string will return a string
Example
x = 5 + 5;
y = “5” + 5;
z = “Hello” + 5;
What happen when you add a number and a string?
the result will be a string
==
equal to
===
equal value and equal type