Full width home advertisement

Grade 10 Revision

Post Page Advertisement [Top]

QBASIC OUTPUT DEBUG ANALYTICAL COLLECTION SET-3

SET - 3
11. Rewrite the following program after correcting the bugs.
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

Ans: Correct program
Rem to display the contents of a data file.
OPEN “Marks.dat” FOR INPUT AS #1
CLS
WHILE NOTEOF(1)
INPUT #1, Name$, Age, Add$
PRINT Name$, Age, Add$
WEND
CLOSE #1
END

12. Write down the output of the following program:
DECLARE FUNCTION area(L,B)
LET L=10
LET B=5
PRINT “The area=”; area(L,B)
END

FUNCTION area(L,B)
A=L*B
area=A
END FUNCTION

Ans: Output
The area= 50

13. Analyse the program and answer the following question:
DECLARE SUB ABC(X,Y,Z)
FOR P=1 TO 3
READ A,B,C
CALL ABC(A,B,C)
NEXT P
DATA 5,4,3,2,1,6,7,8,4
END
SUB ABC(X,Y,Z)
T=X+Y+Z
IF T MOD 2 = 0 THEN
PRINT T
END IF
END SUB

a) List any two variables used in the above program.
Ans: Two variables used in the above program are: A and B.

b) How many times SUB-procedure will be called when program is executed?
Ans: SUB-procedure will be called 3 times when the program is executed.

No comments:

Post a Comment

Bottom Ad [Post Page]