data [Autosaved]
data [Autosaved]
Why do
we need different data
types?
Data is any raw fact, figure, or value that can be recorded and processed
by a computer.
It can be:
•Numbers (e.g., 25, 3.14)
•Text (e.g., "Alice", "Password123")
•Dates (e.g., 07/04/2025)
•True/False values (e.g., TRUE, FALSE)
•Characters (e.g., 'A', 'B', '!’)
Store Information
•Example: In a school database, we store student names, grades
and attendance.
Process Information
•A computer processes data to turn it into something useful.
•Example: Calculate the average marks of students based on their
scores.
Make Decisions
•Computers use data to make logical decisions.
•Example:
IF temperature > 30 THEN OUTPUT "Turn on the
fan"
Perform Calculations
•Without data, no calculations could be done!
•Example: Billing systems, online banking, budgeting apps.
Data Type Description Pseudocode Example
TYPE Student
DECLARE StudentID : STRING
DECLARE Name : STRING
DECLARE Grade : CHAR
DECLARE DOB : DATE
DECLARE HasPaidFees : BOOLEAN
ENDTYPE
•You are creating a custom data structure called Student.
•It contains:
•StudentID (e.g., "ST101") – a STRING
•Name (e.g., "Alice") – a STRING
•Grade (e.g., 'A') – a CHAR
•DOB (e.g., 12/10/2005) – a DATE
•HasPaidFees (e.g., TRUE or FALSE) – a BOOLEAN
Create a Record Variable and Assign
Values
• newStudent.StudentID ← "ST101"
• newStudent.Name ← "Alice"
• newStudent.Grade ← 'A'
• newStudent.DOB ← 12/10/2005
• newStudent.HasPaidFees ← TRUE
•newStudent is a variable of type Student.
•Using dot notation (newStudent.Name, etc.), you assign values to
each
field of the record.
For example:
•The student ID is "ST101"
•The student’s name is "Alice"
•The grade is 'A'
•The date of birth is 12/10/2005
•The fees have been paid, so HasPaidFees is TRUE
Display Student’s Name
OUTPUT newStudent.Name
What this does:
Alice
Check if Fees Are Not Paid and Display Message
a. Defining a Record
b. TYPE Student DECLARE StudentID : STRING
c. DECLARE Name : STRING
d. DECLARE Grade : CHAR
e. DECLARE DOB : DATE
f. DECLARE HasPaidFees : BOOLEAN
g. ENDTYPE
✅ Explanation:
•TYPE Student starts the definition of a new record
structure.
•It groups different types of data under one name.
Creating a Record Variable
newStudent.StudentID ← "ST123“
newStudent.Name ← "Aisha"
newStudent.Grade ← 'A’
newStudent.DOB ← 15/09/2006
newStudent.HasPaidFees ← TRUE