0% found this document useful (0 votes)
8 views4 pages

Debug

Uploaded by

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

Debug

Uploaded by

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

Readersnepal

menu
brightness_2
assignmentLok Sewa Aayog
assignmentOnline Exams
airplayE-Notes
castYour Notes
archiveReaders Club
codeProgrammingarrow_drop_down
vertical_align_bottomLogin
assistantSign Up
ENOTES
Solved debug QBASIC program
access_time
Jan 05, 2022
remove_red_eye
3442

In Secondary Education Examination of Nepal altogether 15 marks of weightage is


carried by QBASIC portion only, Out of which 2 marks question regarding debugging
is always asked. Student will be given with program having syntactical error and
are requested to debug the given program. In this question students have to search
for the wrong syntax normally called bug and eliminate it with the correct syntax.
Following are some of the frequently repeated debugging questions with solution.

Rewrite the given program after correcting the bugs.

Q1)

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


DECLARE SUB FIBO()
CLS
EXECUTE FIBO
END
SUB FIBO
A=2
B=2
FOR Ctr=5 to 1
DISPLAY A;B;
A=A+B
B=A+B
NEXT Ctr
END FUNCTION
Solution:

DECLARE SUB FIBO()


CLS
CALL FIBO
END
SUB FIBO
A=2
B=2
FOR Ctr=5 to 1 STEP -1
PRINT A;B;
A=A+B
B=A+B
NEXT Ctr
END SUB
Q2)
DECLARE FUNCTION reverse$(N$)
INPUT "Any string";N$
X$=reverse$(N$)
PRINT N$
END
FUNCTION reverse (N$)
L=LEN$(N$)
FOR X=L to 1 STEP -1
A$=MID$(N$,X,1)
B$=B$+A$
NEXT X
B$=reverse$(N$)
END SUB
Solution:

DECLARE FUNCTION reverse$(N$)


INPUT "Any string";N$
X$=reverse$(N$)
PRINT X$
END
FUNCTION reverse$(N$)
L=LEN(N$)
FOR X=L to 1 STEP -1
A$=MID$(N$,X,1)
B$=B$+A$
NEXT X
reverse$=B$
END SUB
Q3)

REM To store name and age in a sequental data gile STD.DOC


OPEN STD.DOC FOR OUT AS#1
INPUT "Enter name";N
INPUT "Enter age";A
WRITE 1,N$,A
CLOSE #1
END
Solution:

OPEN "STD.DOC" FOR OUTPUT AS #1


INPUT "Enter name";N$
INPUT "Enter age";A
WRITE #1,N$,A
CLOSE #1
END
Q4)

REM To store name and age in a sequential data file REC.DAT


CLS
OPEN "Employee.dat" FOR OUTPUT AS #1
DO
INPUT "Enter employee's name";N$
INPUT "Enter employee's address";A$
INPUT "Enter employee's age";A1
INPUT "Enter employee's gender";G$
INPUT "Enter employee's salary";S
WRITE #1,A$,A1,G$,S
INPUT "Add more records(Y/N)";A
LOOP WHILE UCASE(A$)="Y"
CLOSE 1
END
Solution:

OPEN "REC.DAT" FOR OUTPUT AS #1


DO
INPUT "Enter employee's name";N$
INPUT "Enter employee's age";A1
WRITE #1,N$,A1
INPUT "Add more records(Y/N)";A$
LOOP WHILE UCASE$(A$)="Y"
CLOSE #1
END
Q5)

CLS
OPEN "check.dat" FOR INPUT AS #1
DO WHILE NOT EOF(3)
INPUT #1,N$,D$,PH,A$
PRINT "Name=";N$
PRINT "DOB=";D$
PRINT "Phone=";PH
PRINT "Address=";A
LOOP
CLOSE #
END
Solution:

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
Q6)

CLS
OPEN "MARKS.DAT" FOR INPU AS #1
PRINT "Roll Number","Name","English","Nepali","Maths"
DO WHILE NOT EOF()
INPUT #1,RN,N$,E,Ne,M
PRINT R,N$,E,Ne,M
END WHILE
CLOSE #1
END
Solution:

CLS
OPEN "MARKS.DAT" FOR INPUT AS #1
PRINT "Roll Number","Name","English","Nepali","Maths"
DO WHILE NOT EOF(1)
INPUT #1,RN,N$,E,Ne,M
PRINT RN,N$,E,Ne,M
LOOP
CLOSE #1
END
© 2024 Copyright ReadersnepalPrivacy Policy

You might also like