File Handling, QBASIC , Class 10, Important Questions with their answers:
1. Storing Student Information
OPEN "ABC.TXT" FOR OUTPUT AS #1
FOR I = 1 TO 5
INPUT "Enter roll, name, class, and address: ", R, N$, C, A$
WRITE #1, R, N$, C, A$
NEXT I
CLOSE #1
END
2. Inserting Staff Records
OPEN "hospital.dat" FOR APPEND AS #1
FOR I = 1 TO 15
INPUT "Enter staff name, post, shift, and age: ", N$, P$, S$, AGE
WRITE #1, N$, P$, S$, AGE
NEXT I
CLOSE #1
END
3. Storing Sales Information
OPEN "sales.txt" FOR OUTPUT AS #1
FOR I = 1 TO 10
INPUT "Enter item's name, rate, and quantity: ", name$, rate, quantity
WRITE #1, name$, rate, quantity
NEXT I
CLOSE #1
END
4. Creating Employee Records
OPEN "employee.dat" FOR OUTPUT AS #1
DO
INPUT "Enter employee name, post, address, and salary: ", name$, post$, adr$, sal
WRITE #1, name$, post$, adr$, sal
INPUT "Want to add more records: ", choice$
LOOP WHILE UCASE$(choice$) = "Y"
CLOSE #1
END
5. Creating Salary Records
OPEN "salary.dat" FOR OUTPUT AS #1
DO
INPUT "Enter employee name, post, and salary: ", name$, post$, salary
WRITE #1, name$, post$, salary
INPUT "Want to add more records: ", choice$
LOOP WHILE UCASE$(choice$) = "Y"
CLOSE #1
END
6. Storing Student Results
OPEN "result.txt" FOR OUTPUT AS #1
DO
INPUT "Enter name, class, and marks of three subjects: ", n$, c, s1, s2, s3
total = s1 + s2 + s3
WRITE #1, n$, c, s1, s2, s3, total
INPUT "Want to add another record: ", choice$
IF UCASE$(choice$) = "Y" THEN GOTO top
LOOP
CLOSE #1
END
7. Storing Employee Information
OPEN "emp.txt" FOR OUTPUT AS #1
top:
sn = 1
INPUT "Enter name, address, and post: ", n$, a$, p$
WRITE #1, sn, n$, a$, p$
sn = sn + 1
INPUT "Want to add another record: ", choice$
IF UCASE$(choice$) = "Y" THEN GOTO top
CLOSE #1
END
8. Filtering Students by Class
OPEN "class.txt" FOR OUTPUT AS #1
top:
INPUT "Enter name, roll, and class: ", n$, roll, class
IF class = 10 THEN
WRITE #1, n$, roll, class
END IF
INPUT "Want to add another record: ", choice$
IF UCASE$(choice$) = "Y" THEN GOTO top
CLOSE #1
END
9. Storing Passed Students
OPEN "pass.txt" FOR OUTPUT AS #1
top:
INPUT "Enter name, marks in Eng, Math, and Computer: ", n$, e, m, c
IF e >= 40 AND m >= 40 AND c >= 40 THEN
WRITE #1, n$, e, m, c
END IF
INPUT "Want to add another record: ", choice$
IF UCASE$(choice$) = "Y" THEN GOTO top
CLOSE #1
END
10. Displaying Student Records
OPEN "record.txt" FOR INPUT AS #1
PRINT "Name", "Age", "City", "Telephone"
WHILE NOT EOF(1)
INPUT #1, n$, age, city$, tel$
PRINT n$, age, city$, tel$
WEND
CLOSE #1
END
Netra Koirala
Computer Science Educator
Passionate computer science educator and author. Provides free study notes, practical guides, and tutorials for Class 9, 10, 11, 12, and B.Sc CSIT students in Nepal. Years of teaching experience in computer science fundamentals.
LinkedIn ProfileRelated Posts
Loading related posts…
Computer Science notes, tutorials, MCQs, and educational resources for Nepal students. Covering Class 9, SEE preparation, Class 11, Class 12, SLC, programming, DBMS, networking, HTML, JavaScript, PHP, OOP and more.
Featured Post
Grade 10 Computer Science: Specification Grid & Model Questions
Specification Grid & Model Questions of Computer Science | Grade 10 📚 Examination Resource Specification Grid & M...