Tuesday 14 April 2020

Write a program to open the data file “BOOK.DAT” with the field of information such as Book Title, Author & Price in input mode and copy all the records having price more than 500 into new data file (“COSTLY.DAT”).

Write a program to open the data file “BOOK.DAT” with the field of information such as Book Title, Author & Price in input mode and copy all the records having price more than 500 into new data file (“COSTLY.DAT”).

Solution:

CLS

OPEN “BOOK.DAT” FOR INPUT AS #1

OPEN “COSTLY.DAT” FOR OUTPUT AS #2

PRINT “BOOK TITLE”, “AUTHOR”, “PRICE”

WHILE NOT EOF (1)

INPUT #1, B$, A$, P

IF P>500 THAN

WRITE #2, B$, A$, P

END IF

WEND

CLOSE #1,#2

END


No comments:

Post a Comment

MCQ Question Bank Microsoft PowerPoint