Thursday, February 15, 2018

QBasic File Handling Program to Display last 50 records from 500 records

Write a Qbasic program that read the "EMP.DAT" file with Name, Address, Post and Salary columns from E: drive that has 500 records of employees and displays only its last 50 records.

OPEN "E:\EMP.DAT" FOR INPUT AS #1
CLS
FOR i = 1 TO 500
    INPUT #1, n$, a$, p$, s
    IF i >= 450 AND i <= 500 THEN PRINT n$, a$, p$, s

NEXT i
CLOSE #1
END


1 comment:

  1. What if number of reco
    rds are not mentioned and asks you to print last 5 data from the record?

    ReplyDelete