0% found this document useful (0 votes)
2 views3 pages

Chapter 7

Chapter 7 discusses computer file handling, categorizing files into text and binary types. It explains the data hierarchy consisting of characters, fields, records, and files, and outlines various file operations such as declaring, opening, reading, writing, and closing files. Additionally, it includes exercises for writing pseudocode to handle student data files.

Uploaded by

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

Chapter 7

Chapter 7 discusses computer file handling, categorizing files into text and binary types. It explains the data hierarchy consisting of characters, fields, records, and files, and outlines various file operations such as declaring, opening, reading, writing, and closing files. Additionally, it includes exercises for writing pseudocode to handle student data files.

Uploaded by

kktw
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Chapter 7

File Handling and Application


7.1 Understanding Computer File
 A computer file is a collection of data stored in a computer system
 The two categories of files are:
o Text files,
 contain data that can be read in a text editor
 include facts and figures used by business operation
 for example, payroll file that contains employee numbers, names, salaries, etc.
o Binary files, which
 contain data that has not been encoded as text.
 Examples include images and music.

7.2 Understanding the Data Hierarchy


 When businesses store data items on computer systems, they are often stored in data
hierarchy that consists of the following:
o Characters
 letters, numbers, and special symbols, such as “A”, “7”, and “$”
o Fields
 composed of one or more characters, such as roll no, name, phone, etc.
o Records
 groups of fields, a student record might contain roll number, name, phone, etc.
o Files
 groups of related records, such as a student file might contain records of each
student in class

7.3 Performing File Operations


 There are several file operations as follows:
o Declaring a file
Declarations
InputFile studentData
OutputFile updateData

1
o Opening a file
open studentData "[Link]"
open studentData "C:\UniversityFiles\CurrentYear\[Link]"
o Reading from a file
input name from studentData
o Writing to a file
output name, address to updateData
o Closing a file
close studentData
close updateData

Exercise
1. Write a pseudocode to open a new file for writing student data from the student file.
start
Declarations
InputFile studentData
OutputFile updatedData
string roll_no
string name
string phone
string grade

open studentData "[Link]"


open updateData "[Link]"

input roll_no, name, phone from studentData


while not eof
output “Enter Grade:”
input grade
output roll_no, name, phone,grade to updateData
input roll_no, name, phone from studentData
endwhile

2
close employeeData
close updatedData
stop

2. Write a pseudocode to extract male and female list from the student file that consists of
roll_no, name, gender, phone, address and then write these data list into two files call
StudentMaleList and StudentFemaleList.

You might also like