Representing Algorithm Using Pseudocode Part 2
Representing Algorithm Using Pseudocode Part 2
Pseudocode
Third Form
Data types
• A data type describes how data is processed and stored.
We group data with similar characteristics into data types because:
Grouping data gives the following advantages:
Makes it easier for the data tobe identified by the user and the computer.
Speeds up the time the computer takes to process and store these data.
Indicates the type of action that are applicable to the data.
Types of data types
✔ Number (Numeric)
✔ Text (String, Character)
Number (Numeric): means that we can perform a calculation on it.
Numeric data types can be divided into:
✔ Integer - are positive and negative whole numbers including 0..
(+65, -65)
✔ Real - are positive and negative fractional numbers. (+65.9, -
65.9)
✔ Text (Nonnumeric ): Include all letters of the alphabet, special
symbols such as #,%,@ and numbers that will never participate in
arithmetic calculations. For example, car licenses, telephone numbers
and so on.. Data that are text is enclosed in quotation marks.
Text can be further divided into:
✔ A character is a data type consisting of a single letter, symbols, or
digits.
✔ A string is a data type made up of more than one character enclosed
in quotation marks. The “computer” is a string made up of eight
characters. Telephone number “876 928-1584” is also a string.. A
string do not participate in arithmetic operations.
✔ Boolean is a data type that stores true or false value as its value.
Data types
Keyword Purpose
Begin/Start
Input statement (s)
Process statement (s)
Output statement (s)
End/Stop
Input and Output
Keyword Purpose
The input and output
Read, Input Accepts data sections of a pseudocode are
Print, Write Outputs governed by statements that
information begin with special words
called keywords alongside
the relevant variable names.
Input-Output Keyword
Basic Conventions in using keywords
Read or Input
To use the “Read” or “Input” keyword, the word Read or Input must be followed
by a variable name. If more than one value needs to be inputted, then there will be
a need for more than one variables, each variable name separated by a comma.
For example, using ‘Read” to enter the value of a student’s score, you would
write:
Read Score
To input the value of two students’ scores you wouldd write: Read Score1, Score2
OR
Read Score 1
Read Score 2
Note: Each line of statement must begin with an appropriate
keyword.
Using “Input” to allow the user to enter the value of a student’s
score you would write:
Input Score1, Score2
OR
Input Score1
Input Score 2
How to write an input statement?
Num1,Num2,Num3: Integer
Num1 0
Num2 0
Num3 0
Total Num1+Num2+Num3
Print Total
Stop
https://www.youtube.com/watch?v=eSYeHlwDCNA
https://www.youtube.com/watch?v=8AQcIdz8GQs
https://www.youtube.com/watch?v=mQ0VClVd31c
Video links!!!!