FILE HANDLING IN QBASIC (EXERCISE 2)



#A SEQUENTIAL DATA FILE”MARKS.INF” CONTAINS STUDENTS NAME AND MARKS IN MATH, SCIENCE AND COMPUTER OF SOME STUDENTS. WRITE A PROGRAM TO DISPLAY ALL THE RECORDS OF THAT FILE.

CLS

OPEN “MARKS.INF” FOR INPUT AS #1

WHILE NOT EOF(1)

INPUT #1, N$,M,S,C

PRINT N$,M,S,C

WEND

CLOSE #1

END

 

#A SEQUENTIAL DATA FILE “PERSON.INF” CONTAINS NAME, ADDRESS, MOBILE NUMBERS OF 10 PEOPLE. WRITE A PROGRAM TO DISPLAY ALL THE RECORDS OF A FILE.

CLS

OPEN “PERSON.INF” FOR INPUT AS #1

FOR I=1 TO 10

INPUT #1, N$,A$,M#

PRINT N$,A$,M#

NEXT I

CLOSE #1

END

 

#A SEQUENTIAL DATA FILE “SALARY.DAT” CONTAINS THE INFORMATION OF EMPLOYEE REGARDING THEIR NAME, POST AND SALARY. WRITE A PROGRAM TO DISPLAY ALL THE INFORMATION OF EMPLOYEE WHOSE SALARY IS GREATER THAN 15000 AND LESS THAN 40000.

CLS

OPEN “SALARY.DAT” FOR INPUT AS #1

WHILE NOT EOF(1)

INPUT #1, N$,P$,S

IF S>15000 AND S<40000 THEN

PRINT N$,P$,S

END IF

WEND

CLOSE #1

END

 

# A SEQUENTIAL DATA FILE “PATIENT.DAT” CONTAINS PATIENT NAME, DATE OF BIRTH, DISEASE AND GENDER OF 100 PATIENTS. WRITE A PROGRAM TO DISPLAY FIRST 25 RECORDS OF A FILE.

CLS

OPEN “PATIENT.DAT” FOR INPUT AS #1

FOR I = 1 TO 25

INPUT #1, N$,A$,D$,DI$,G$

PRINT N$,A$,D$,DI$,G$

NEXT I

CLOSE #1

END

 

#A SEQUENTIAL DATA FILE “EMP.DAT” CONTAINS NAME, POST AND SALRAY FIELDS OF INFORMATION ABOUT EMPLOYEES. WRITE A PROGRAM TO DISPLAY ALL THE INFORMATION OF EMPLOYEES ALONG WITH TAX AMOUNT. [TAXT IS 15% OF SALARY]

CLS

OPEN “EMP.DAT” FOR INPUT AS #1

WHILE NOT EOF(1)

INPUT #1, N$,P$,S

T=(15/100)*S

PRINT N$,P$,S,T

WEND

CLOSE #1

END

 

#WRITE A PROGRAM TO VIEW THOSE RECORDS FROM  “EMPLOYEE.DAT” SEQUENTIAL DATA FILE HAVING EMPLOYEES NAME, DEPARTMENT, APPOINTMENT DATE AND WHOSE SALARY IS MORE THAN 5000.

CLS

OPEN “EMPLOYEE.DAT” FOR INPUT AS #1

WHILE NOT EOF(1)

INPUT #1, N$,D$,A$,S

IF S>5000 THEN

PRINT N$,D$,A$,S

END IF

WEND

CLOSE #1

END

 

#A SEQUENTIAL DATA FILE “BOOK.INF” CONTAINS BOOK’S NAME, AUTHOR NAME, PRICE OF BOOK AND PUBLICATION NAME OF SOME BOOKS. WRITE A PROGRAM TO DISPLAY RECORDS OF SPECIFIED AUTHOR.

CLS

OPEN “BOOK.INF” FOR INPUT AS #1

INPUT “ENTER SPECIFIED AUTHOR’S NAME”;AUTHOR$

WHILE NOT EOF(1)

INPUT #1, B$,AUT$,PRICE,PUB$

IF UCASE$(AUTHOR$)=UCASE$(AUT$) THEN

PRINT B$,AUT$,PRICE,PUB$

END IF

WEND

CLOSE #1

END

 

#WRITE A PROGRAM TO DISPLAY THE RECORDS OF SEQUENTIAL DATA FILE “ACCOUNT.DAT” ON THE SCREEN. THE DATA FILE HAS THE FOLLOWING RECORDS: NAME, AGE AND PHONE NUMBER.

CLS

OPEN “ACCOUNT.DAT” FOR INPUT AS #1

PRINT “NAME”, “AGE”, “PHONE NUMBER”

WHILE NOT EOF(1)

INPUT #1, N$,A,P

PRINT N$,A,P

WEND

CLOSE #1

END

 


Sujit Prasad Kushwaha

A Dedicated Blogger Sharing Insights and Making a Difference.

Post a Comment

The comment section is your chance to make your mark. Don't hold back - add to the discussion and let your personality shine through!

Previous Post Next Post