Friday, October 18, 2019

177. Qbasic sequential file handling to search data from a data file. If the data is not found, then display the message “Data not found in the list”.

177.A data file named “record.dat” contains name, age and salary for n number of persons. Write a program to input a name to search data from a data file. If the data is not found, then display the message “Data not found in the list”.
OPEN “RECORD.DAT” FOR INPUT AS #1
CLS
INPUT “Enter name to be searched”; S$
FLAG=0
WHILE NOT EOF(1)
INPUT #1, N$, A$, S
IF UCASE$(S$)=UCASE$(N$) THEN
PRINT N$, A$, S
FLAG=1
END IF
WEND
IF FLAG=0 THEN PRINT “Data not found”
CLOSE #1
END

2 comments: