Coding Basics: Variables
Example 1:
x = 5;
y = 3;
z = x + y; //z holds the value 8
Example 2:
a = 7;
a = a + 3; //a holds the value 10
Example 3:
b = 5;
b += 2; //this is a shortcut for b = b + 2, so b now holds the value 7.
Example 4:
c = 3;
c++; //this is a shortcut for c = c + 1, so c now holds the value 4.
Example 5:
d = 5 < 3; //d holds the value false
e = 8 > 6; //e holds the value true
f = d || e; //f holds the value true. The || symbol represents the inclusive "OR". If either d or e (or both) are true, then f is true.
Example 6:
g = true;
h = false;
i = g && h; //i holds the value false. The && symbol represents "AND". If g and h are both true, then i is true.
Example 7:
j = 5.3;
k = 2.4;
l = j + k; //l holds the value 7.7
Example 8:
m = 5 + 3 *4; //m holds the value 17 (Order of Operations)