QBasic programs collection-Especially for SEE (Grade-10)
QBasic program to know the output of program using dry run table- to extract characters and print them
DECLARE FUNCTION OUTPUTT$(W$)
Cls
W$ = "CRIMES"
Print OUTPUTT$(W$)
End
Function OUTPUTT$ (W$)
For M = Len(W$) To 1 Step -2
M$ = M$ + Mid$(W$, M, 1)
Next M
OUTPUTT$ = M$
End Function
DRYRUN table for above program is given below
W$ |
M=6 TO 1
STEP-2 |
M$=M$+MID$(W$,M,1) |
OUTPUTTT$ |
|
|
CRIMES |
M=6 |
M$=S |
|
|
|
|
M=4 |
M$=S+M=SM |
|
|
|
|
M=2 |
M$=SM+R=SMR |
SMR |
|
|
Output:-
SMR
No comments:
Post a Comment