0% found this document useful (0 votes)
3 views16 pages

data [Autosaved]

Data is any raw fact or value that can be processed by a computer, including numbers, text, dates, and boolean values. Different data types are necessary for storing, processing, and making decisions based on information, such as in a student database. A record is a user-defined data structure that groups related variables of different types, allowing for organized data management.

Uploaded by

HAK
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views16 pages

data [Autosaved]

Data is any raw fact or value that can be processed by a computer, including numbers, text, dates, and boolean values. Different data types are necessary for storing, processing, and making decisions based on information, such as in a student database. A record is a user-defined data structure that groups related variables of different types, allowing for organized data management.

Uploaded by

HAK
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 16

What is data?

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', '!’)

Think of data as the "input" we give to a computer so it can work


with it.
We need data because it helps us:

Store Information
•Example: In a school database, we store student names, grades
and attendance.

•Without data, a computer wouldn’t know anything!

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

INTEGER Whole numbers INTEGER age 5, -10, 100

DATE A date value DATE dob 12/10/2005

BOOLEAN True/False BOOLEAN isLoggedIn TRUE, FALSE

REAL Decimal numbers REAL temperature 37.5, -2.3

CHAR A single character CHAR grade 'A', 'b'

STRING Sequence of characters STRING name "Alice", "CS123"


Example: For a student database, what data types would you use for:
• StudentID
• Name
• Grade
• DateOfBirth
• HasPaidFees
•A record is a user-defined data structure that groups related variables
• (of possibly different types) under one name.

•Useful when dealing with real-world entities (e.g., student, employee,


•book).

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:

•It displays the name stored in the Name field of


newStudent,
which is "Alice".

Alice
Check if Fees Are Not Paid and Display Message

IF newStudent.HasPaidFees = FALSE THEN OUTPUT "Reminder to pay fees"


ENDIF

What this does:


•It checks whether the student has not paid the fees.
•If HasPaidFees is FALSE, it shows a reminder message.
•But in this case, the value is TRUE, so this condition is false, and nothing is printed.
Using a Record Structure

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

DECLARE newStudent : Student


•This creates a variable newStudent using the record
structure
Student.
Assigning Data to Record Fields

newStudent.StudentID ← "ST123“
newStudent.Name ← "Aisha"
newStudent.Grade ← 'A’
newStudent.DOB ← 15/09/2006
newStudent.HasPaidFees ← TRUE

•This assigns values to each field in the record.


•Fields are accessed using dot notation
(recordName.fieldName).
Concept Purpose
Defines a record structure (like a custom
TYPE...ENDTYPE data group)
A record variable that uses the Student
newStudent structure
← Assigns a value

OUTPUT Displays a value

IF...THEN...ENDIF Checks a condition and runs code only if


the condition is true

You might also like