✅ File Handling in QBasic Class 10 (SEE Exam Notes)
File handling in QBasic is one of the most important topics for Class 10 SEE Examination. It helps us store data permanently in a file so that we can use it later even after the program is closed.
In SEE exams, file handling programs are commonly asked, so students must understand the commands like OPEN, CLOSE, PRINT#, INPUT#, WRITE#, EOF etc.
✅ What is File Handling in QBasic?
File Handling in QBasic is the process of storing and retrieving data using files. A file is a collection of data stored in secondary memory such as hard disk.
Unlike variables (temporary storage), files store data permanently.
✅ Why File Handling is Important for SEE Exam?
File handling is important because:
It is a common SEE programming question
It stores records like name, roll no, marks etc.
It helps in permanent data storage
It is used in schools for record management
✅ Types of Files in QBasic
In Class 10 SEE syllabus, mostly we study:
1. Sequential File
A file where data is stored and read in sequence (order).
Example: Student record file.
✅ File Handling Commands in QBasic
Here are the most important file handling commands:
🔹 OPEN
Used to open a file.
🔹 CLOSE
Used to close a file.
Used to write data into a file.
🔹 INPUT
Used to read data from a file.
🔹 WRITE
Used to store data in proper format.
🔹 EOF()
Checks if the file has ended.
🔹 LINE INPUT
Reads full line/text from a file.
✅ File Modes in QBasic
✅ 1. OUTPUT Mode
Creates a new file and writes data. Old data gets deleted.
Syntax:
OPEN "student.txt" FOR OUTPUT AS #1
✅ 2. INPUT Mode
Reads data from an existing file.
Syntax:
OPEN "student.txt" FOR INPUT AS #1
✅ 3. APPEND Mode
Adds new data at the end of file.
Syntax:
OPEN "student.txt" FOR APPEND AS #1
✅ Important Syntax of File Handling in QBasic
General Syntax:
OPEN "filename" FOR mode AS #filenumber
Example:
OPEN "data.txt" FOR OUTPUT AS #1
✅ SEE Exam Programs for File Handling in QBasic
✅ Program 1: Write Student Name into File
CLS
OPEN "student.txt" FOR OUTPUT AS #1
INPUT "Enter student name: "; N$
PRINT #1, N$
CLOSE #1
PRINT "Data saved successfully."
END
✅ Program 2: Read Student Name from File
CLS
OPEN "student.txt" FOR INPUT AS #1
INPUT #1, N$
PRINT "Student Name is: "; N$
CLOSE #1
END
✅ Program 3: Store Name and Marks in File
CLS
OPEN "marks.txt" FOR OUTPUT AS #1
INPUT "Enter Name: "; N$
INPUT "Enter Marks: "; M
PRINT #1, N$
PRINT #1, M
CLOSE #1
PRINT "Record Saved!"
END
✅ Program 4: Display All Records from File Using EOF()
CLS
OPEN "marks.txt" FOR INPUT AS #1
WHILE NOT EOF(1)
INPUT #1, A$
PRINT A$
WEND
CLOSE #1
END
✅ Program 5: Append New Data into File
CLS
OPEN "student.txt" FOR APPEND AS #1
INPUT "Enter new name: "; N$
PRINT #1, N$
CLOSE #1
PRINT "New record added successfully."
END
✅ Viva Questions (SEE Important)
Q1. What is file handling?
File handling is the process of storing and retrieving data permanently using files.
Q2. What is sequential file?
A sequential file stores and reads data in order.
Q3. Write modes used in OPEN statement.
INPUT, OUTPUT, APPEND
Q4. What is EOF?
EOF means End Of File. It checks whether file data is finished.
Q5. Why should we close a file?
To save data properly and free memory.
✅ Conclusion
File handling in QBasic is an important topic for Class 10 SEE examination. By learning commands like OPEN, CLOSE, PRINT#, INPUT#, and EOF, students can easily write SEE-level programs. Practicing these programs will help score good marks in practical and written exams.