Wednesday, May 5, 2021

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

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

1.

REM to display all the records from sequential data file ABC.DAT
OPEN “ABC.DAT” FOR OUTPUT AS # 1

DO WHILE NOT EOF(“ABC.DAT”)
INPUT # 1,N$,A
PRINT N$,A
CLOSE 1
END


2.


Rem to display the contents of a data file.
OPEN “Marks.dat” FOR OUTPUT AS #1
CLS
WHILE EOF(1)
               INPUT #1, Name$, Age, Add$
               DISPLAY Name$, Age, Add$
WEND
CLOSE 1
END


3. 


REM display Records of students From Data File

OPEN “STDREC.DAT” FOR INP AS #1

PRINT “ROLL”, ”NAME”, ”ADDRESS”, ”CLASS”, ”SECTION”

DO WHILE NOT EOF

        INPUT #1,RN,N$,AD$,CL,S$

        PRINT RN,N$,AD$,CL,S$

NEXT

CLOSE #1

 END


4. 


REM To store Name, post and salary

OPEN “EMP.DOC” FOR OUT AS #1

INPUT” Enter name”;N

INPUT” Enter post”;P$

INPUT “Enter salary”;S

WRITE #2, N$,P$, S

CLOSE #1

END


5. 


OPEN "STUDENT.DAT" FOR APPEND AS 1#
INPUT "NAME"; N$
INPUT "ADDRESS"; ADD$
INPUT "AGE"; AGE$
WRITE #1, N$, ADD$, AGE
END# 1
STOP


6. 


REM Program to read data from the data file.

OPEN “STD.DAT” FOR OUTPUT AS #1

CLS

WHILE NOT EOF(#1)

WRITE#1, N$, R, C, P

PRINT N$, R, C, P

WEND

CLOSE “STD.DAT”

END 


7.


Rem To print only class 10 record from "student.dat" CLS

OPEN "I",#2, "Student.Dat"

WHILE NOT EOF (#2)   

WRITE#2, N$,C,R   

IF C=10 THEN            

DISPLAY N$,C,R   

END IF

NEXT

CLOSE #2

END


8.


REM to store name and age in a  sequential data file STD.DAT
OPEN STD.DAT FOR OUTPUT AS #1
INPUT “Enter name”; N
INPUT ”Enter age”; A
WRITE 1, N$, A
END


9. 


RREM TO READ RECORDS FROM DATA FILE
OPEN STUD.DAT FOR OUTPUT AS #1
WHILE NOT EOF(2)
LINE INPUT #2, REC$
PRINT REC$
LOOP
CLOSE #3
END


10.


OPEN ”C:\NEA.TXT” FOR OUTPUT #1

DO WHILE EOF(1)

INPUT #,N$,PMR,CMR,NMR

PRINT  N$,PMR,CMR,NMR

WEND

CLOSE #1

END





No comments:

Post a Comment