Download - Report Group 4 Constants and Variables(TLE)
![Page 1: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/1.jpg)
3. Avoid using confusing letters or numbers such as zero and the letter O
Examples: One_0, Ph0ne_Num
4. Use underscore (_) in replacement of a spaceExamples: Class_Num, Birth_date
5. Lessen the number of character of your variable. The shorter the better.
Examples: Int_Flight, Loc_Flight.Lbl1
6. In most cases, upper and lowercases are read differently. A and a may hold different data
Example: B,b
![Page 2: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/2.jpg)
![Page 3: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/3.jpg)
LEARNING OBJECTIVESAfter the report the students should be able to:
Define what constants areExplain the meaning and use of operators
Learn and evaluate arithmetic operators properly
Learn and use relational opeartorsDefine and use logical operators
![Page 4: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/4.jpg)
![Page 5: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/5.jpg)
CONSTANTSConstants are values that do
not change during the execution of the program.
Example:Pi=3.1416X=100
![Page 6: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/6.jpg)
![Page 7: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/7.jpg)
OPERATORSAn operator is a symbol or
a character indicating an operation that acts on one or more elements. These elements are refered to as operands
![Page 8: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/8.jpg)
OPERANDS An operand is the object of a mathematical
operation or a computer instruction. The number of operands depends on the programming language you use.
For Example:Pascal Programming Language contains
constants, data, variables, and other arithmetic expressions.
![Page 9: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/9.jpg)
CLASSIFICATION of OPERATORSArithmetic OperatorsLogical OperatorsRelational OperatorsAssignment Operators
![Page 10: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/10.jpg)
Arithmetic Operators They are operators that perform mathematical operations or calculations
It can involve two or more numeric arguments (operands)
These operators are similar to what the 4 fundamental operations
![Page 11: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/11.jpg)
FUNCTION OPERATOR
Addition + (plus sign)
Subtraction - (minus sign)
Multiplication * (asterisk)
Division / (slash)
Modular Division/ Modulus mod
Integer Division div
Exponentiation ^ (caret sign)
Negation - (minus sign)
![Page 12: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/12.jpg)
+ and -+ operators are just
the same as addition in real life as well as subtraction
Example:25 + 25 = 5069 + 1 = 7050 +70 = 120
- operators are just the same with the real life subtraction
Example:75-5 = 70100-50=5070-50= 20
![Page 13: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/13.jpg)
* and /Just like the addition
and subtraction operational principle; multiplication is just the same
Example:3*9 = 279*9 = 81
Just like the addition and subtraction operational principle division is just the same
Example:25/5 = 581/9 = 9
![Page 14: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/14.jpg)
DivIt computes ONLY
the integral part of the result of dividing its first operand to its second operand
An integral part is defined as an integer or whole number such as 1, 10, or 5
2 72
3.5
1
7 div 2
![Page 15: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/15.jpg)
Mod
Modulus returns the integer remainder of a division.
Examples:7 mod 2Result:16 mod 2Result:0
2 72
3
1
7 div 2
7 mod 2
![Page 16: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/16.jpg)
^ and - Exponentiation is
self explanatory. It only means that a number can be expressed with an exponents
Example:4^56^23
Negation makes a number in its negative form
Example:- (5) = -5- (43) = -43
![Page 17: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/17.jpg)
HEIRARCHY of ARITHMETIC OPERATIONS
It is also called OPERATOR PRECEDENCE. It refers to the priority of the various operators when more than one is used in an expression. Parenthesis are used as the need arises.
![Page 18: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/18.jpg)
EXPRESSIONExpression in programming, is a combination of symbols, identifiers, values and operators that yield a result upon evaluation
![Page 19: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/19.jpg)
NEMDASMo Method1st: Negation2nd: Exponentiation3rd:Multiplication and Division4th: Addition and Subtraction5th: Modulus
![Page 20: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/20.jpg)
Example:5+(4*2/2)-3=65+(8/2)-3(5+4)-39-36
![Page 21: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/21.jpg)
LESSON TERMSOperatorArithmetic OperatorOperandDivModIntegerExpression
![Page 22: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/22.jpg)
Write your answers in a one whole sheet of paper. Copy the given values and variables.
![Page 23: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/23.jpg)
VALUES and VARIABLESA = 2B = 22C = 3D = 23E = 5F = 10G = 20H = 30
![Page 24: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/24.jpg)
H/C/(E-A)F*H-G*ED+A+C*E-G/FA+B*3(H+G)/EH+G/E
![Page 25: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/25.jpg)
PLEASE EXCHANGE NOTEBOOKS to YOUR CHEATMATES
1. 302. 2003. 384. 685. 346. 10
![Page 26: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/26.jpg)
Assignment OperatorsIs used to assign values to variables. You can assign any type of data to a variable, real, integer, char and boolean.
The sign for assignment operator is :=
![Page 27: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/27.jpg)
Assignment StatementsIt always consist of a variable on the left hand
side of an assignment operator, and an expression on a right side
The expression can be a variable, a number, or any complicated expression made up of variables, numbers and arithmetic operators
It instructs the computer to evaluate the expression and assign value of its result to the variable
Form: Variable := Expression
![Page 28: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/28.jpg)
Illustrative Example
PROD := N1 * N2VARIABLE
EXPRESSIONASSIGNMENT OPERATOR
![Page 29: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/29.jpg)
This statement would assign the product of the expression N1*N2 to the variable PROD. Since the value of a variable can be changed during the program execution, the value of the variable PROD could also change depending on the value stored in any of the two variables N1 and N2
![Page 30: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/30.jpg)
ExampleNUM1 := 15;FirstLetter := ‘A’;X := 6;Y := X;Z = Y + NUM1
![Page 31: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/31.jpg)
The number 6 there is assigned to the variable X, then in the fourth statement, the variable X is assigned to the variable Y
![Page 32: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/32.jpg)
A variable on the right-hand side of an assignment statement must first be given a value before it can be used in an assignment statement. A variable without an assigned value is called an uninitialized variable
![Page 33: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/33.jpg)
Relational Operators Operators that are used to compare
two values basing on certain conditions.yield a true or false resultForm: value | relational operator |
valueThe operands of a relational operator
must be of the same data type, or one maybe type real and the other type integer
![Page 34: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/34.jpg)
FUNCTION OPERATOR
Greater than >
Less than <
Equal to =
Not equal to <>
Greater than or Equal to >=
Less than or Equal to <=
![Page 35: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/35.jpg)
EXAMPLEEXAMPLE RESULTRESULT
8>58>5 True True
8<58<5 FalseFalse What happened in here What happened in here was a was a type mismatchtype mismatch
8=88=8 TrueTrue
8<>58<>5 TrueTrue
8>=108>=10 FalseFalse What happened here What happened here was a was a type mismatchtype mismatch
8<=98<=9 TrueTrue
![Page 36: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/36.jpg)
Relational operators ALWAYS result to Boolean Values (true or false). There are only two possible values for relational operators and this can only be either the value TRUE, and value FALSE
![Page 37: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/37.jpg)
LESSON TERMSAssignment OperatorAssignment StatementRelational OperatorsBoolean Values
![Page 38: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/38.jpg)
In your notebook
![Page 39: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/39.jpg)
![Page 40: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/40.jpg)
Write the correct statement for the following values to the given variables1. Assign the value 250 to DailyRate2. Assign the product of 100 and 200 to the
variable Product3. Assign the value of X to MyValue4. Assign the total of the product of X and Y
and W and Z to Total5. Assign the value of Total (No.4) to the values
of ExtremeTotality
![Page 41: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/41.jpg)
Determine the Boolean ValueIf A = 100If B = 200If C = 300If D = 400If E = 500
1. (B*C) > (C*B)2. ((A*C)+D) = ((A*D)
+C)3. E < 5004. A + D <= E5. (A + B + C + D + E)
>= 15000
![Page 42: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/42.jpg)
PLEASE EXCHANGE NOTEBOOKS to YOUR CHEATMATES
1. DailyRate := 2502. 100*200 := Product3. MyValue := X4. X*Y*W*Z := Total5. X*Y*W*Z := Total :=
ExtremeTotality or Total := ExtremeTotality
![Page 43: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/43.jpg)
PLEASE EXCHANGE NOTEBOOKS to YOUR CHEATMATES
1. (60,000) > (60, 000) FALSE2. 30,400 = 40,300 FALSE3. 500 < 500 FALSE4. 500 <= 500 TRUE5. 1500 >= 15000
FALSE
![Page 44: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/44.jpg)
Logical OperatorsThey are also called as Boolean OperatorsBoolean operators are operators that
evaluate expressions and determine whether the conditions specified by the expressions are either true or false
Requires boolean operators
![Page 45: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/45.jpg)
KINDS OF BOOLEAN OPERATOR
The AND OperatorThe OR OperatorThe NOT Operator
![Page 46: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/46.jpg)
The AND OperatorThe and operator evaluates to true, only if both its operands (or expressions) are true.
![Page 47: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/47.jpg)
(X > 75) and (Y > 75)
![Page 48: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/48.jpg)
If both expressions (X > 75) and (Y >75) include in the statement evaluate to true (if both X and Y values are greater than 75), then the above statement will evaluate to true, otherwise, the statement will evaluate to false.
![Page 49: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/49.jpg)
AND OperatorOperand / Expression
1
Operand/ Expression
2
Decision
True True TrueTrue False FalseFalse True FalseFalse False False
![Page 50: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/50.jpg)
ILLUSTRATIVE EXAMPLETRUE - TRUE TRUE - FALSE
(34 <> 23)(12 <> 23)
True
(97 > 32)(24 <> 24)
False
![Page 51: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/51.jpg)
ILLUSTRATIVE EXAMPLEFALSE - TRUE FALSE - FALSE
(12 <> 23)(14 <= 23)
False
(12 <> 23)(23 < 23)
False
![Page 52: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/52.jpg)
The OR OperatorThe OR Operator determines whether one or
both of its operands (or expressions) are true or false .
![Page 53: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/53.jpg)
(X = 1) or (X = 3)
![Page 54: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/54.jpg)
If one of the expressions in the statement is true, the statement evaluates to true. This means that if X is equal to either 1 or 3, then the statement is true. For example if, X=4 then the statement above returns the value false
![Page 55: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/55.jpg)
OR OperatorOperand / Expression
1
Operand/ Expression
2
Decision
True True TrueTrue False TrueFalse True TrueFalse False False
![Page 56: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/56.jpg)
ILLUSTRATIVE EXAMPLETRUE - TRUE TRUE - FALSE
(4=4)(5=5)
True
(E=5)(5 <>5)
True
![Page 57: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/57.jpg)
ILLUSTRATIVE EXAMPLEFALSE- TRUE FALSE-FALSE
(45>56)(12 <> 23)
True
(9 >= 32)(24 <> 24)
False
![Page 58: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/58.jpg)
The NOT OperatorThe NOT Operator has a single operand which it evaluates to either true or false.
It returns the opposite of the value returned by the variable
![Page 59: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/59.jpg)
If passed is true, then not passed is false
If passed is false, then not passed is true
![Page 60: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/60.jpg)
NOT OperatorOperand / Expression 1
Operand / Expression 2
Operand / Expression 1 Decision
Operand / Expression 2 Decision
True True False False
True False False True
False True True False
False False True True
![Page 61: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/61.jpg)
OPERATOR PRECEDENCEOPERATOR PRECEDENCE
Not
*, /, div, mod, and
+ , -, or
<, <=, =, <>, >=, >
Highest (evaluated first)
Lowest (evaluated last)
![Page 62: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/62.jpg)
LESSON TERMSBoolean OperatorAndOrNotOperator Precedence
![Page 63: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/63.jpg)
In your notebook
![Page 64: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/64.jpg)
Determine the Boolean values returned by the following operators with the given valuesX: 100Y: 50A: 200B: 75Condition: trueFlag: false
1. (X>105) or (B>50)2. (X=75) and (X>75)3. (A<>B) or (X = Y)4. (not condition) and (not flag)5. Not flag6. ((X*2)=200) and (X=100)7. (X<75) or (Y<75)8. ((A+B)>250) or ((X+Y)>150)9. (not condition)10. (B<50) and (A=200)
![Page 65: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/65.jpg)
Answers:1. True2. False3. True4. False5. True6. True7. True8. True9. False10.False
![Page 66: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/66.jpg)
GET THE TOTAL NUMBER of SCORENumber
Topic Items
1 Arithmetic Operators 5
2 A Assignment Operators 5
2 B Relational Operators 5
3 Boolean/ Logical Operators
10
25
![Page 67: Report Group 4 Constants and Variables(TLE)](https://reader035.vdocuments.us/reader035/viewer/2022062511/54be399b4a7959b1568b45db/html5/thumbnails/67.jpg)
By Group 4