Full width home advertisement

Grade 10 Revision

Post Page Advertisement [Top]

QBASIC OUTPUT DEBUG ANALYTICAL COLLECTION SET-2

SET 2
11. Re-write the given program correcting the bugs:
Rem program to reverse the string or word
DECLARE SUB REV(W$)
CLS
INPUT “Enter a wod”;W$
CALL REV(W$)
END
SUB REV(W$)
FOR I=LEN(W$) to 1 step -1
C$=LEFT$(W$,I,1)
S$=D$+1
LOOP
PRINT “Reverse string is:”; D$
CLOSE SUB

Ans: Correct program
Rem program to reverse the string or word
DECLARE SUB REV(W$)
CLS
INPUT “Enter a wod”;W$
CALL REV(W$)
END
SUB REV(W$)
FOR I=LEN(W$) to 1 step -1
C$=MID$(W$,I,1)
D$=D$+C$
NEXT I
PRINT “Reverse string is:”; D$
END SUB

12. Write the output of the following program.
DECLARE SUB Series()
CLS
CALL Series
END
SUB Series
A=1
B=1
FOR I = 1 TO 2
PRINT A; B;
A=A+B
B=A+B
NEXT I
END SUB

Ans: Output
1 1 2 3

13. Analyse the program given below and answer the questions:
DECLARE FUNCTION CHK$(N)
CLS
N=57
PRINT “The number is”; CHK$(N)
END
FUNCTION CHK$(N)
FOR I = 1 TO N
IF N MOD I = 0 THEN C=C+1
NEXT I
IF C>2 THEN
CHK$=”Composite”
ELSE
CHK$=”Prime”
END IF
END FUNCTION
a) Will the above program execute if “DECLSRE FUNCTION….” Is deleted
Ans: Yes, the above program will execute if “DECLARE FUNCTION…..” is deleted.
b) Why $ sign is used in the name of the above function.
Ans: $ sign is used in the name of the above function because it returns a string value

No comments:

Post a Comment

Bottom Ad [Post Page]