LESSON 3 - Algorithm Representation
LESSON 3 - Algorithm Representation
S TOPIC:
Variables &
Data Types
ACT_1
Variables &
Data Types
Identify the data types of the following
variables – character, integer, floating-
point, boolean, string.
studentName allowance
yearLevel civilStatus
gender address
age interestRate
course idNumber
salary absent
graduating weight
ACT_2
Operators
Determine the result of the ff.
expressions using the order of
precedence.
Assume that A = 2, B = 4, C = 3, D = 5
1. (B / A) + D * C = (4/2) + 5 * 3 = 2 + 5
* 3 = 2 + 15 = 17
2. (B / A) – D + B * C
3. (B * C) + D – C
4. C%A–B*C
5. A+B*C–D%A
Determine the truth value of the ff.
statements using the given values of A,
B, C, & D.
1. (A + B) > 10 AND A < B
= (2 + 4) > 10 AND 2 < 4
= 6 > 10 AND 2 < 4
= false AND true
= false
2. A <> 10 OR B > 5
3. B / A < 10 AND NOT D – 2 > 5
4. A <> 2 OR B >= 2 AND A + B == 6
5. B – A > 5 OR NOT C <> A
LESSON
3
Algorithm
Representation
Algorithm
According to Donald Knuth, algorithms are the
threads that tie together most of the subfields of
computer science.
An algorithm is:
1. an ordered sequence of instructions for doing a
task or solving a problem
It
is important that algorithms are
unambiguous and precise as possible.
Properties of an Algorithm
An algorithm must have the following
properties:
Assignment
Assignment is used to store a value. This might involve
either (a) simply storing a value or (b) calculating the
answer to an arithmetic problem and then storing the
result.
Examples:
Display "Width = ", width
Display "Hello World"
Display grossIncome, taxPayable
Initialize sum to 0
Prompt the user to enter the first integer
Read user's first integer input
Prompt the user to enter a second integer
Read user's second integer input