Full width home advertisement

Grade 10 Revision

Post Page Advertisement [Top]

QBASIC OUTPUT DEBUG ANALYTICAL COLLECTION SET-10

SET -10

11. Re-write the given program after correcting the bugs:
CREATE FUNCTION square(A)
Rem to print square of a number
CLS
Get “a number”; A
CALL square(A)
END

FUNCTION square(A)
Ans=A^2
Square=Ans
END Square(A)

Ans: Correct program
DECLARE FUNCTION square(A)
Rem to print square of a number
CLS
INPUT “a number”; A
PRINT square(A)
END

FUNCTION square(A)
Ans=A^2
Square=Ans
END FUNCTION

12. Write the output of the following program:
DECLARE SUB Series()
CALL Series
END
SUB Series
A=2
B=2
For ctr=1 to 2
PRINT A; B;
A= A+B
B=A+B
Next ctr
END SUB

Ans: Output
2 2 4 6

13. Analyse the program given below and answer the questions:
Declare function count(N$)
Input “Enter a word”; R$
C= Count(R$)
Print C
END
Function count(N$)
For k=1 to LEN(n$)
X$=MID$(N$,K,1)
IF UCASE$(X$)=”A” then
X=X+1
End if
Next K
Count = X
End function

i) List any two library functions used in the above program.
Ans: Any two library functions used in the above program are: MID$ and LEN.

ii) Write the use of variable ‘C’ inline 3 [i.e. C=Count(R$)] given in the above program.
Ans: The use of variable “C”inline 3 [i.e. C=Count(R$)] given in the above program is to store the value returned by the function Count.

No comments:

Post a Comment

Bottom Ad [Post Page]