Uploaded by Jeremy Ryan Chiwawu

Pseudocode Operators and Operations

advertisement
COMPUTER SCIENCE 0478
PSEUDOCODE
MATHEMATICAL OPERATIONS
Operation
Symbol Example Answer
6+9
15
Addition
+
12 - 4
8
Subtraction
12 * 5
60
Multiplication
*
18/3
6
Division
/
2^4
16
Raise to the power of
^
The same operations are carried out in nearly all programming languages
RELATIONAL OPERATORS
Operator
=
<
>
>=
Meaning
Equal to
Less than
Greater than
Greater than or equal to
<=
Less than or equal to
<>
Not equal to
Example
45 = 45
16 < 20
24 > 20
20>=15
20>=20
19<=25,
19<=19
17 <> 30
LOGICAL OPERATORS (BOOLEAN OPERATORS)
(A Boolean value is either TRUE or FALSE, YES or NO, 1 or 0
Boolean
Expression
20 > 5
20 < 5
15 > = 10
18>=100
18=100
32/4 = 8
Boolean value
TRUE, YES or 1
FALSE, NO or 0
TRUE, YES or 1
FALSE, NO or 0
FALSE, NO or 0
TRUE, YES or 1
The following operators are often used in pseudocode and in programming:
LOGICAL
Operator
AND
OR
NOT
Boolean value
Example
Will yield TRUE if
both expressions are
TRUE
Will yield TRUE if one
of the expressions (or
both) is TRUE
Makes a FALSE
condition TRUE or
vice versa
X > 5 AND x < 10
COUNTING
Count
Count + 1
SUMMING
Sum
Sum + Number
END OF HANDOUT
Age< 16 OR
Gender=”Female”
NOT (15>20)
NOT(A > B)
Download