Sikshya Plus Get appGet the app free
Class 10 · Computer Science

File Handling in QBASIC – Class 10 Computer Science Notes and Solutions

Complete solutions and answers for “File Handling in QBASIC”, a chapter in Class 10 Computer Science (SEE exam preparation). This page covers The lesson in short, Section A: File Concepts, Modes, and File I/O Statements, Section B: Complete Solved File Handling Programs and Section C: Textbook Review Questions & Answers.

  • Free, no login needed
  • 4 min read
  • Updated 20 November 2026

Chapter at a glance

Complete study guide and programming solutions for Class 10 Computer Science Unit 10 File Handling in QBASIC, covering file modes (OUTPUT, INPUT, APPEND), file I/O statements (WRITE#, INPUT#, LINE INPUT#), the EOF() function, and full programs for creating, reading, and filtering data records.

  • Sequential File Modes: OUTPUT vs INPUT vs APPEND
  • File Opening and Closing Statements: OPEN, CLOSE
  • Data Writing and Reading: WRITE# vs PRINT#, INPUT#
  • The EOF() Function and While Loops
  • File Management Programs: Student Records and Filtering

Exam focus: Writing complete QBASIC programs to create and display sequential data files, explaining OUTPUT vs APPEND mode differences, and utilizing EOF() correctly.

Key formulas and definitions

  • File loop template: WHILE NOT EOF(1) ... INPUT #1, vars ... WEND
On this page (9 sections)
  1. The lesson in short
  2. Section A: File Concepts, Modes, and File I/O Statements
  3. File ModesSequential File Opening Modes
  4. Section B: Complete Solved File Handling Programs
  5. Create FileProgram 1: Create a Sequential File and Store Student Records
  6. Read FileProgram 2: Read and Display All Records from File
  7. Filter FileProgram 3: Filter and Display High-Achieving Students
  8. Section C: Textbook Review Questions & Answers
  9. Review Q&AConceptual Review Q&A

Solutions and answers

Class 10 Computer Science · Unit 10: File Handling in QBASIC

The lesson in short

File handling in QBASIC provides persistent secondary storage capabilities, enabling programs to store, retrieve, update, and manage structured records on disk beyond temporary computer memory.

While variables vanish from RAM when a program terminates, data files preserve customer accounts, student databases, inventory stocks, and employee payrolls reliably across sessions.

This chapter covers file modes (OUTPUT, INPUT, APPEND), file manipulation statements (OPEN, CLOSE, WRITE#, PRINT#, INPUT#, LINE INPUT#), file status functions (EOF, LOF, LOC), and practical record-management programs aligned with the CDC Class 10 syllabus.

Section A: File Concepts, Modes, and File I/O Statements

File ModesSequential File Opening Modes

Access ModeSyntax PatternOperating Purpose & Pointer BehaviorExisting File Overwrite Risk
OUTPUTOPEN "filename.dat" FOR OUTPUT AS #1Creates a new sequential file for writing data; positions pointer at beginningDestructive: Overwrites existing file data completely
INPUTOPEN "filename.dat" FOR INPUT AS #1Opens an existing sequential file for reading data; pointer at beginningRead-only mode; runtime error if file does not exist
APPENDOPEN "filename.dat" FOR APPEND AS #1Opens file for writing new records at the end of the existing fileSafe: Preserves existing records; appends new data to the end
Statement / FunctionSyntax TemplateSpecific Functionality in File Handling
OPENOPEN file$ FOR mode AS #file_numAssociates an external disk file with an internal file stream buffer number
CLOSECLOSE #1, #2 (or CLOSE)Flushes cached memory buffers to disk and terminates file association
WRITE #WRITE #1, name$, roll%, marks!Writes formatted records to disk, automatically inserting delimiters and quotes around strings
INPUT #INPUT #1, name$, roll%, marks!Reads delimited record values sequentially from disk file into designated variables
LINE INPUT #LINE INPUT #1, line_str$Reads an entire line of text up to the carriage return into a single string variable
EOF()WHILE NOT EOF(1)End-of-File boolean function; returns True (-1) when the end of file is reached

Section B: Complete Solved File Handling Programs

Create FileProgram 1: Create a Sequential File and Store Student Records

Write a QBASIC program to create a sequential data file named "STUDENT.REC" and store Name, Roll Number, Class, and Total Marks for N students.

CLS

OPEN "STUDENT.REC" FOR OUTPUT AS #1

INPUT "How many student records do you want to add? ", n%

FOR i% = 1 TO n%

PRINT "--- Student #"; i%; " ---"

INPUT "Enter Student Name: ", sname$

INPUT "Enter Roll Number: ", roll%

INPUT "Enter Class: ", cls%

INPUT "Enter Total Marks: ", marks!

WRITE #1, sname$, roll%, cls%, marks!

NEXT i%

CLOSE #1

PRINT "Records successfully written to STUDENT.REC."

END

Read FileProgram 2: Read and Display All Records from File

Write a QBASIC program to read and display all student records stored in "STUDENT.REC" in tabular format.

CLS

OPEN "STUDENT.REC" FOR INPUT AS #1

PRINT "========================================================="

PRINT "NAME ROLL CLASS MARKS"

PRINT "========================================================="

WHILE NOT EOF(1)

INPUT #1, sname$, roll%, cls%, marks!

PRINT sname$; TAB(22); roll%; TAB(33); cls%; TAB(44); marks!

WEND

PRINT "========================================================="

CLOSE #1

END

Filter FileProgram 3: Filter and Display High-Achieving Students

Write a program to display only those students from "STUDENT.REC" whose Total Marks are 80 or above.

CLS

OPEN "STUDENT.REC" FOR INPUT AS #1

PRINT "Distinction Students (Marks >= 80):"

PRINT "---------------------------------------------------------"

count% = 0

WHILE NOT EOF(1)

INPUT #1, sname$, roll%, cls%, marks!

IF marks! >= 80 THEN

PRINT "Name: "; sname$; " | Roll: "; roll%; " | Marks: "; marks!

count% = count% + 1

END IF

WEND

IF count% = 0 THEN PRINT "No student scored 80 or above."

CLOSE #1

END

Section C: Textbook Review Questions & Answers

Review Q&AConceptual Review Q&A

1. What is the difference between OUTPUT mode and APPEND mode in QBASIC file handling?

Both OUTPUT and APPEND modes are used to write data into a sequential data file. However, if a file already exists on disk, opening it in OUTPUT mode completely deletes and overwrites all existing data, starting fresh from the beginning. In contrast, opening an existing file in APPEND mode strictly preserves all previously stored records and places the write pointer at the very end of the file, allowing new records to be safely added without data loss.

2. What is the purpose of the EOF() function in QBASIC file processing?

The `EOF()` (End of File) function checks whether the file read pointer has reached the end of an open sequential data file. It returns a boolean value: False (0) as long as records remain to be read, and True (-1) when no further data exists. It is most commonly used in a `WHILE NOT EOF(file_number)` loop to read all records sequentially without triggering an "Input past end of file" runtime error.

Frequently asked questions

What is File Handling in QBASIC about?

Complete study guide and programming solutions for Class 10 Computer Science Unit 10 File Handling in QBASIC, covering file modes (OUTPUT, INPUT, APPEND), file I/O statements (WRITE#, INPUT#, LINE INPUT#), the EOF() function, and full programs for creating, reading, and filtering data records.

Which topics are covered in File Handling in QBASIC?

Class 10 Computer Science “File Handling in QBASIC” covers: Sequential File Modes: OUTPUT vs INPUT vs APPEND; File Opening and Closing Statements: OPEN, CLOSE; Data Writing and Reading: WRITE# vs PRINT#, INPUT#; The EOF() Function and While Loops; File Management Programs: Student Records and Filtering.

What should I focus on in File Handling in QBASIC for the exam?

Writing complete QBASIC programs to create and display sequential data files, explaining OUTPUT vs APPEND mode differences, and utilizing EOF() correctly.

What are the key formulas or definitions in File Handling in QBASIC?

File loop template: WHILE NOT EOF(1) ... INPUT #1, vars ... WEND.

Where can I read the Class 10 Computer Science “File Handling in QBASIC” solutions?

Right on this page. They are free and you do not need to sign up. For chapter quizzes and the AI tutor, install the Sikshya Plus app.

Study tips

Free for Class 9 to 12

Do not just read it. Practice it.

You have read the solutions for File Handling in QBASIC. Now test yourself, ask the AI tutor and keep your streak going.

Sikshya Plus chapter quiz screen with class, subject and difficulty options
Sikshya AI personal tutor chat inside the app
Sikshya Plus AI tools screen: question assistant, summarizer, translator, grammar checker
Chapter list with Past Q, materials, posts and books tabs
  • AI quizzes for this chapterTest yourself with instant feedback and explanations after every answer.
  • AI tutor, free, 24/7Stuck on a question? Ask in your own words and get a step-by-step explanation.
  • 14 AI tools in one appSummarizer, grammar checker, flashcards, essay help, math solver and more.
  • Past questions and notesPast papers and your own notes organized chapter by chapter.
Download free on Google Play Scan with your phone to install