0% found this document useful (0 votes)
2 views2 pages

debug program

The document contains a series of REM programs written in BASIC that demonstrate various functionalities such as generating a specific sequence of numbers, reversing strings, and storing employee information in sequential data files. It includes code snippets for inputting and writing data to files, as well as displaying information. The programs illustrate basic programming concepts like loops, functions, and file handling.

Uploaded by

Elsing tamang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

debug program

The document contains a series of REM programs written in BASIC that demonstrate various functionalities such as generating a specific sequence of numbers, reversing strings, and storing employee information in sequential data files. It includes code snippets for inputting and writing data to files, as well as displaying information. The programs illustrate basic programming concepts like loops, functions, and file handling.

Uploaded by

Elsing tamang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

REM program to generate 2,2,4,6,10 upto 10th


term. Ans:
DECLARE SUB FIBO() DECLARE FUNCTION reverse$(N$)
CLS cls
EXECUTE FIBO INPUT "Any string";N$
END X$=reverse$(N$)
SUB FIBO PRINT X$
A=2 END
B=2 FUNCTION reverse$(N$)
FOR Ctr=5 to 1 L=LEN(N$)
DISPLAY A;B; FOR X=L to 1 STEP -1
A=A+B A$=MID$(N$,X,1)
B=A+B B$=B$+A$
NEXT Ctr NEXT X
END FUNCTION reverse$=B$
Ans: END SUB
DECLARE SUB FIBO() REM To store name and age in a sequental data gile
CLS STD.DOC
CALL FIBO OPEN STD.DOC FOR OUT AS#1
END INPUT "Enter name";N
SUB FIBO INPUT "Enter age";A
A=2 WRITE 1,N$,A
B=2 CLOSE #1
FOR Ctr=5 to 1 STEP -1 END
PRINT A;B; Ans:
A=A+B OPEN "STD.DOC" FOR OUTPUT AS #1
B=A+B INPUT "Enter name";N$
NEXT Ctr INPUT "Enter age";A
END SUB WRITE #1,N$,A
QN2. CLOSE #1
DECLARE FUNCTION reverse$(N$) END
INPUT "Any string";N$ REM To store name and age in a sequential data file
X$=reverse$(N$) REC.DAT
PRINT N$ CLS
END OPEN "Employee.dat" FOR OUTPUT AS #1
FUNCTION reverse (N$) DO
L=LEN$(N$) INPUT "Enter employee's name";N$
FOR X=L to 1 STEP -1 INPUT "Enter employee's address";A$
A$=MID$(N$,X,1) INPUT "Enter employee's age";A1
B$=B$+A$ INPUT "Enter employee's gender";G$
NEXT X INPUT "Enter employee's salary";S
B$=reverse$(N$) WRITE #1,A$,A1,G$,S
END SUB INPUT "Add more records(Y/N)";A
LOOP WHILE UCASE(A$)="Y"
CLOSE 1
END

Ans: Qn.6
OPEN "REC.DAT" FOR OUTPUT AS #1
DO CLS
INPUT "Enter employee's name";N$ OPEN "MARKS.DAT" FOR INPU AS #1
INPUT "Enter employee's age";A1 PRINT "Roll
WRITE #1,N$,A1 Number","Name","English","Nepali","Maths"
INPUT "Add more records(Y/N)";A$ DO WHILE NOT EOF()
LOOP WHILE UCASE$(A$)="Y" INPUT #1,RN,N$,E,Ne,M
CLOSE #1 PRINT R,N$,E,Ne,M
END END WHILE
CLOSE #1
END
QN.
CLS Ans:
OPEN "check.dat" FOR INPUT AS #1
DO WHILE NOT EOF(3) CLS
INPUT #1,N$,D$,PH,A$ OPEN "MARKS.DAT" FOR INPUT AS #1
PRINT "Name=";N$ PRINT "Roll
PRINT "DOB=";D$ Number","Name","English","Nepali","Maths"
PRINT "Phone=";PH DO WHILE NOT EOF(1)
PRINT "Address=";A INPUT #1,RN,N$,E,Ne,M
LOOP PRINT RN,N$,E,Ne,M
CLOSE # LOOP
END CLOSE #1
Ans: END
CLS
OPEN "check.dat" FOR INPUT AS #1
DO WHILE NOT EOF(1)
INPUT #1,N$,D$,PH,A$
PRINT "Name=";N$
PRINT "DOB=";D$
PRINT "Phone=";PH
PRINT "Address=";A$
LOOP
CLOSE #1
END

You might also like