Solved examples of APPEND mode
in File Handling
1. Write a program to add
few new records in existing data file “record.dat” which has contents student name,
class and roll no.
OPEN
"record.dat" FOR APPEND AS #1
DO
INPUT
"Enter name=";n$
INPUT
"Enter class=";c$
INPUT
"Enter Roll no=";r
WRITE
#1,n$,c$,r
INPUT
"Do you need more records to add=";ans$
LOOP
WHILE UCASE$(ans$)="Y"
CLOSE
#1
2. A sequential data file called
‘student.dat’ contains some records under the fields name, English, Nepali and Computer.
Write a 3 program to add some more records in the same sequential data file. (SLC
2068)
OPEN “student.dat” FOR
APPEND AS #1
TOP:
INPUT “Enter name=”;n$
INPUT “Enter English =”;e
INPUT “Enter Nepali=”;n
INPUT “Enter computer=”;c
WRITE #1, n$,E,N,C
INPUT “Do you want more
data=”;Ans$
IF Ans$=”Y” OR Ans$= “y”
THEN GOTO top
CLOSE #1
END
OPEN
“SLC.DAT” FOR APPEND AS #1
FOR
I = 1 TO 15
CLS
INPUT
“Enter students name”; N$
INPUT
“Enter class”; C
INPUT
“Enter marks in three subjects”; M1, M2, M3
WRITE
#1, N$,C,M1,M2,M3
NEXT
I
CLOSE
#1
END
Also Read: Arguments in QBASIC using modular programming for class 10 and SEE
No comments:
Post a Comment