Wednesday, May 5, 2021

Debugging - SLC / SEE Computer Science - Sequential File Handling - Qbasic Programs [Set 3]

 Debugging - SLC / SEE Computer Science - Sequential File Handling - Qbasic Programs [Set 3]

21.

REM to display records from 2nd position to 6th position.
OPEN record.txt FOR INPUT AS #2
DO WHILE EOF(2)
INPUT #1, N, Add$, DOB$
C=C+1
IF C<=2 AND C>=6 THEN
PRINT N$, Add$, DOB$
END IF
LOOP
CLOSE #2
END

22.

REM add data to existing data file

DIM n, p, c AS STRING

OPEN “file.txt” FOR OUTPUT AS 1

DO

      INPUT “Enter name, post”; n, p

      WRITE n, p

INPUT “Press y/Y to add more”; c

LOOP WHILE c = “Y” or c = “y”

CLOSE 1

END


23.


REM to add records in a sequential data file.
OPEN "STUDENT.DAT" FOR INPUT #1
DO
INPUT "Enter name, class and roll no."; N$, C, R
PRINT #1, N$, C, R$
INPUT "Do you have more records(y/n)"; y$
UNTIL LCASE$(Y)= "n"
END

24.

REM to update the salary by 10%

CLS

OPEN "EMP.DAT" FOR INPUT AS #1

OPEN "TEMP.DAT" FOR OUTPUT AS#1

WHILE NOT EOF(1)

INPUT NM$, POST$, S

LET  NS = S + S*10/100

WRITE NM$, POST$,NS

WEND

KILL "EMP.DAT"

CLOSE #1,#2

NAME "TEMP.DAT" AS "EMP.DAT"

END

25.

REM to copy the data of “src.txt” to “dest.txt”

OPEN “SRC.TXT” FOR INPUT AS #1

OPEN “DEST.TXT” FOR OUTPUT AS #2

CLS

WHILE NOT EOF( )

INPUT #2, NAME$, ROLL, AGE

WRITE #1, NAME$, ROLL, AGE

CLOSE

END

26.

REM store records

        CLS

        OPEN "peaks.xls" FOR INPUT AS #75

        DO

               INPUT "Enter peak"; P$

               INPUT "Enter district";D

               INPUT "Height"; H

               WRITE P$,D$,H

               INPUT "Do U 1 2 add more";mor$

        LOOP WHILE UCASE$(mor$)="y"

            CLOSE #75

27.

CLS

REM copy the data of 'mark.dat' file to 'update.dat' file.

OPEN "MARK.DAT" FOR OUTPUT AS #1

OPEN "UPDATE.DAT" FOR INPUT AS #2

DO UNTIL EOF ( )

    Input #2, RollNumber, Name$, Age

    WRITE #1, RN, N$, AGE

CLOSE#1, 2

LOOP

END



No comments:

Post a Comment