QBASIC program to create, Read and Append students data from "student.dat" data file (Class 10 SEE)

3 years ago

QBASIC File Handling Program

Write a program to create a sequential data file "student.dat" then store Name, Class Roll number, and Address of the student.

CLS
OPEN "student.dat" FOR OUTPUT AS #1
INPUT "Enter Name : "; n$
INPUT "Enter Class : "; c
INPUT "Enter Roll No : "; r
INPUT "Enter Address : "; a$
WRITE #1, n$, c, r, a$
CLOSE #1
END

 

Write a program to display all the records of data file "student.dat"


CLS
OPEN "student.dat" FOR INPUT AS #1
PRINT "Name", "class", "Roll No.", "Address"
DO WHILE NOT EOF(1)
    INPUT #1, n$, c, r, a$
    PRINT n$, c, r, a$
LOOP
CLOSE #1
END

 

Write a program to add some new records in the existing data file "student.dat" The program should prompt the user for adding the next records.


CLS
OPEN "student.dat" FOR APPEND AS #1
top:
INPUT "EnterName : "; n$
INPUT "Enter Class : "; c
INPUT "Enter Roll No. : "; r
INPUT "Enter Address : "; a$
WRITE #1, n$, c, r, a$
INPUT "Any more records ? (Y/N) : "; ch$
IF ch$ = "Y" OR ch$ = "y" THEN GOTO top
CLOSE #1
END
  5477