Section 5 - Plans and Expression
1. Arithmetic operator
code:
A = B + C / / a = b plus c
A = B-C / / a = b c reduced
A = B * C / / a = b c multiplied
A = B / c / / a = b divided by c
A = B% C / / a = b for the remaining c - 10% 3 = 1; 8% 3 = 2
code:
A + +; / / same as A plus 1
/ / example:
A = 1; / / A is the same as the 1
A + +;
Print (A); / / A value at this time 2 (1 +1)
A + +;
Print (A); / / A value at this time 3 (because of added
1 more)
code:
B -; / / same as above, only 1 was reduced
B = 1;
B -;
Print (B); / / current value is 0 B
2. Assignment operator
the general use only =
I have many, there is + =, -=,% = etc., but rarely use
& quite hard to understand .. Anything I so in the
future course
code:
a = b * 5; / / enter the value multiplied b 5
to a
a + = 5; / / A the same as a +5
a-= 5; / / A is the same as the a-4
3. Relational operator (operator benchmark)
code:
==: Equal
! =: Not equal
<: Less than
>: Greater than
<=: Less than or equal to
> =: Greater than or equal to
example the implementation of
code:
if (a == b) () / / if a is the same as the b
if (a> b) () / / if a is greater than b
if (a! = b) () / / if not equal to a b
4. Logical operators
there are only 3 that are important
& &: And
| |: Or
! : Not
example implementation:
code:
if (a == b & & c <d) () / / if a is
the same as the b and c is smaller than d
if (a == b | | c> = d) () / / if a b is the same
as the one (not as a means of b) or c greater than or
equal to d
=========
There are several other operators, such as bitwise operators,
but not too used to the simple EA, so I just Anything
later.
Hopefully useful to all
of us ..
Click the register when
you are ready!
Section
6 - Decision and Looping: the use of branching and looping
to set the EA program flow.
|