Problem-Solving 0 Program Design
Problem-Solving 0 Program Design
const const
Hr = 3600; pi = 3.142;
DATA TYPES
⦿ Data types determines the type of data that a variable
can store
⦿ Types of data types are:
◼ Integers – negative and positive whole numbers (23, -76)
◼ Floating point/real - decimal or fractional values (0.345, ½)
◼ Character (char) – a single letter or symbol (L, a, %, *)
◼ String – combination of characters (fruit)
◼ Boolean – has two possible values ( True or false)
ACTIVITY
State the data types for the following:
⦿ Name
⦿ Age
⦿ Yes/No
⦿ Taxi fare
⦿ M/F
ACTIVITY
State whether the following in an appropriate variable
name
⦿ 3num
⦿ First_name
⦿ Last name
⦿ Char
⦿ 7894
⦿ monthoftheyear
ACTIVITY
Declare the following variables:
⦿ Name
⦿ Age
⦿ Yes/No
⦿ Taxi fare
⦿ M/F
ACTIVITY
Declare the following constants
⦿ Days of the week
⦿ Months of the year
⦿ Pi
⦿ Hours in a day
⦿ Minutes in a hour
TYPES OF ALGORITHMS
⦿ Narrative
◼ This is a representative of an algorithm where each
instruction is written in everyday language
⦿ Pseudocode
◼ This is using instructions with words and symbols that closely
resemble computer programming language
⦿ Flowchart
◼ This is a graphical representation of an algorithm that uses
symbols to depict input, process and output
PSEUDO CODE
⦿A pseudo code can contain
◼ Variables
◼ Constants
◼ Operators
◼ Terminology
OPERATORS - ARITHMETIC
ARITHMETIC OPERATOR OPERATION
+ Addition
- Subtraction
* Multiplication
/ Division
MOD Produces the remainder in the
result (11 MOD 2) = 1
DIV Integer division – produces only
the whole number in the result
(11 DIV 2) = 5
OPERATORS - RELATIONAL
RELATIONAL OPERATOR OPERATION
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
<> Not equal to
= Equal to
OPERATORS - LOGICAL
LOGICAL OPERATOR OPERATION
AND And
OR Or
NOT Not
TRUTH TABLE - NOT
⦿ Truth tables are tables illustrating the use of the
logical operators NOT, AND and OR