Friday, October 18, 2019

175. Qbasic sequential file handling to opy all the records of class 10 into a newly created file new.dat


175.A sequential data file named “abc.dat” has several records having fields name, roll and class. Write a program to copy all the records of class 10 into a newly created file new.dat.

OPEN "ABC.DAT" FOR INPUT AS #1
OPEN "NEW.DAT" FOR OUTPUT AS #1
CLS
WHILE NOT EOF (1)
  INPUT #1, N$, R, C
IF C = 10 THEN WRITE #2, N$, R, C   
WEND
CLOSE #1, #2
END


1 comment: