QBASIC PROGRAM Find
Output With Dry Run
1. Write
the output of the given program: Show with dry run in
table. [2]
DECLARE SUB
SHOW(A)
CLS
N=87
CALL SHOW(N)
END
SUB SHOW(A)
DO
B=A MOD 6+3
IF B MOD 4=0
THEN GOTO AA
PRINT B;
AA:
A=A-10
LOOP WHILE
A>=50
END SUB
2. Write
the output of the given program: (Workout with dry
run) [2]
DECLARE
FUNCTION OUTPUT1(A)
CLS
N=135
CALL
OUTPUT1(N)
END
SUB
OUTPUT1(A)
DO WHILE A
< > 0
R = A MOD 10
T = T + R
A = A \ 10
LOOP
PRINT T
END SUB
3. Write down the output of the given program. Show with dry
run in
table.
[2]
DECLARE SUB Num ( )
CLS
CALL Num
END
SUB Num
N=2
A=5
C=1
WHILE C <= 9
PRINT N
N=N*3+A
A=A-1
C=C+2
WEND
END SUB
4.
Write the output of the given program showing the dry
table.
[2]
DECLARE SUB
series()
CLS
CALL series
END
SUB series()
A=11111
C=5
WHILE
C>=1
PRINT A;
A=A\10
C=C-1
WEND
END SUB
5. Write down the output of the given program with dry run
table. [2]
DECLARE
SUB NUMBER ()
CLS
CALL
NUMBER
END
SUB
NUMBER
N=3:C=1
WHILE
C<=5
PRINT
N
N=N*10+3
C=C+1
WEND
END
SUB
6. Write down the output of the given program. (2)
DECLARE SUB
SERU ( )
CLS
CALL SERU
END
SUB SERU ()
X=2
C=1
WHILE
C<=10
S=X^C
PRINT S;
C=C+1
WEND
END SUB
7. Write
down the output of the given programs. [2]
DECLARE SUB DISPLAY (A)
CLS
A= 3
CALL DISPLAY (A)
END
SUB DISPLAY
(A)
FOR X = 1 TO
6
PRINT A;
IF A MOD 2 =
0 THEN
A=A/2
ELSE
A= (A*3)+1
END IF
NEXT X
END SUB
8. Write
down the output of the given program. Show with dry run in table: [2]
DECLARE SUB SERIES(X)
CLS
X=7
CALL
SERIES(X)
END
SUB
SERIES(X)
FOR M = 1 TO
10
PRINT X;
IF X MOD 2=0
THEN
X=X/2
ELSE
X=3*X+1
END IF
NEXT M
END SUB
9. What will
be output?
DECLARE FUNCTION FACT (N)
CLS
N=5
PRINT FACT (N)
END
FUNCTION FACT (N)
F=1
FOR I=1 TO N
F=F*I
NEXT I
FACT=F
END FUNCTION
10. Write
the output of the given program: (Workout with a dry run). 2
DECLARE SUB ABC(A)
CLS
A=2
CALL ABC(A)
END
SUB ABC(A)
FOR J= 1 TO 5
PRINT A;
A=A+3;
NEXT J
END SUB
11. Write
down the output of the given program:
DECLARE SUB
Series(A)
CLS
A=20
CALL
Series(A)
END
SUB
Series(A)
FOR K=1 to 5
PRINT A;
A=A+10
NEXT K
END SUB
12. Write
the output of the given program showing the dry run table.
DECLARE SUB
result ( )
CLS
CALL result
END
SUB result (
)
FOR I = 9 to
1 step -2
Sum = sum +
i^2
NEXT i
13. Write down the output of the given program. Show
with dry run in table.
DECLARE SUB
SERIES ()
CLS
CALL SERIES
END
SUB SERIES (
)
X=1
Y=2
FOR P 1 TO
10
PRINT X:
X=X+Y
Y=Y+1
NEXT P
END SUB
14. Write
down the output of the given program. Show with dry run in table .
DECLARE SUB
SERI()
CLS
CALL SERI
END
SUB SERI
X# = 1
FOR I = 1 TO
5
PRINT X# *
X#
X# = X# * 10
+1
NEXT I
END SUB
15. Write
the output of the given program. Show with dry run in table.
2
DECLARE SUB SERIES()
CLS
CALL SERIES
END
SUB SERIES( )
X#=11111
FOR I= 1 TO
5
PRINT X#^2
X# = (X# -
1) / 10
NEXT I
END SUB
16. Write
the output of the given program showing the dry run table. (2)
DECLARE FUNCTION PRO(N)
CLS
A=2
FOR J=1 TO 5
X= PRO(A)
PRINT X
NEXT J
END
FUNCTION PRO(N)
N=N+2
PRO=N
END FUNCTION
17. Write the output of the given program. Show with
dry run in table. [2]
DECLARE SUB SERIES ( )
CALL SERIES
END
SUB SERIES
A = 1
FOR I = 1 TO 5
PRINT I * A
A = A+ (10 ^ I)
NEXT I
END SUB
18. Write
down the output of the given program.
DECLARE
SUB ptt()
CLS
CALL patt
END
SUB patt
X=1
FOR i=1 TO 5
PRINT X
X=(x*10)+i
NEXT i
END SUB
19. Write
down the output of the given program. Show with the dry run in table.
DECLARE SUB
SERI ( )
CLS
CALL SERI
END
SUB SERI
A$ = "SCIENCE"
B = LEN (A$)
FOR I = 1 TO 4
PRINT TAB(I); MID$(A$, I, B)
B =B-2
NEXT I
END SUB
END SUB
20. Write
down the output of the given program. Show with dry run in table.
2
DECLARE SUB Result(C$)
C$=”COMPUTER”
CALL Result(C$)
END
SUB Result(C$)
FOR C=1 TO LEN(C$) STEP 2
M$=MID$(C$,C,1)
N$=N$+M$
NEXT C
END SUB
21.
Write the output of the following program. Show dry run in table. [2]
DECLARE FUNCTION EXAM$(W$)
W$ = "COMPUTER"
PRINT EXAM$(W$)
FUNCTION EXAM$ (W$)
FOR P = 1 TO LEN(W$)
K$ =
MID$(W$, P, 1)
IF P
MOD 2 = 0 THEN
K$
= LCASE$(K$)
ELSE
K$
= UCASE$(K$)
END
IF
S$ =
S$ + K$
NEXT P
EXAM$ = S$
END FUNCTION
22. Write down the output of the given program and
show them in dry run table: [2]
DECLARE
SUB CITY (K$)
CLS
CALL
CITY ("KATHMANDU")
END
SUB
CITY (K$)
FOR
K = 1 TO LEN (K$)
C$
= MID$ (K$, K, 1)
IF
K MOD 2 = 1 THEN
C$
= UCASE$ (C$)
ELSE
C$
= LCASE$ (C$)
END
IF
X$
= X$ + C$
NEXT
K
PRINT
X$
END
SUB
23.
FIND OUTPUT ALONG WITH DRY RUN
DECLARE
SUB SERIES ( )
CLS
CALL SERIES
END
SUB SERIES
A$="NEPAL"
B=1
FOR I=1 TO
LEN(A$) STEP 2
IF B <
> 3 THEN
PRINT
MID$(A$,B,I)
ELSE
PRINT
MID$(A$,1,I)
END IF
B=B+1
NEXT I
END SUB
24. Write down
the output of the given program. \Show with dry run in table.
(2)
DECLARE
SUB PATTERN(SS)
CLS
B$="PROGRAM"
CALL
PATTERN(B$)
END
SUB
PATTERN(S$)
H=LEN(S$)
I=10
FOR J=1 TO H
STEP 2
H=H-2
PRINT
TAB(I); MID$(S$,J,H)
I=I+1
NEXT J
END SUB
25. Write down the output of the given
program.
[2]
DECLARE FUNCTION TEXT$(A$)
CLS
A$= “TECHNOLOGY”
Y$= TEXT$(A$)
PRINT Y$
END
FUNCTION TEXT$(A$)
B= LEN(A$)
FOR I = 1 TO B
IF I MOD 2 = 1 THEN
B$= B$+MID$(A$,I,1)
END IF
NEXT I
TEXT$= B$
END FUNCTION
26. Write
down the output of the following along with dry run table. 2
DECLARE
SUB SENDUP(S$)
E$=
“NPABSON"
CALL
SENDUP(E$)
END
SUB
SENDUP(S$)
FOR i = 1 to
LEN(S$) STEP 1
IF i MOD
2<>0 THEN
EE$=EE$+LCASE$(MIDS(S$,I,1))
ELSE
EE$=EE$+UCASE$(MIDS(S$,I,1))
END IF
NEXT i
PRINT EE$
END SUB
27. Write
down the output of the following program with dry run table.
DECLARE SUB
REG(M,N$,T)
CLS
A=1
X$=”PABSON”
CALL
REG(A,X$,T)
END
SUB
REG(M,N$,T)
FOR
I=LEN(N$) TO 1 STEP-1
PRINT
MID$(N$,I,M)
M=M+1
NEXT I
END SUB
No comments:
Post a Comment