1. Write down the output of the given program. Show with dry run in table.
SEE (Supplementary/Upgrade) 2075 (2019)
DECLARE FUNCTION SUM (a)
CLS
a = 9
PRINT SUM (a)
END
FUNCTION SUM (a)
FOR K = 1 TO a
IF K MOD 2 = O THEN
S = S + K
END IF
NEXT K
SUM = S
END FUNCTION
Answer:Dry Run:
FOR I= 1 to a(9) | K MOD 2 = 0 | S=S+K |
1 | No | - |
2 | Yes | S=0+2=2 |
3 | No | - |
4 | Yes | S=2+4=6 |
5 | No | - |
6 | Yes | S=6+6=12 |
7 | No | - |
8 | Yes | S=12+8=20 |
9 | No | - |
2. Write down the output of the given program. Show with dry run in table.
SEE 2075 (2019) Province-2DECLARE FUNCTION SQD(N) CLS S = 0 FOR L = 1 TO 3 READ NUM S = S +SQD (NUM) NEXT L PRINT " Sum" ; S DATA 2,4,6 END FUNCTION SQD (N) SQD = N^2 END FUNCTION
Answer:Dry Run:
L | N | SQD=N^2 | S=S+SQD(NUM) |
1 | N=2 | SQD=2*2=4 | S=0+4=4 |
2 | N=4 | SQD=4*4=16 | S=4+16=20 |
3 | N=6 | SQD=6*6=36 | S=20+36=56 |
3. Write down the output of the given program. Show with dry run in table.
SEE 2075 (2019)DECLARE SUB series ( ) CALL series END SUB series X = 1 FOR K = 1 TO 4 PRINT X; X = X + K NEXT K END SUB
Answer:Dry Run:
X | K | Print X; | X=X+K |
1 | 1 | 1 | X=1+1=2 |
2 | 2 | 2 | X=2+2=4 |
4 | 3 | 4 | X=4+3=7 |
7 | 4 | 7 | X=7+4=11 |
4. Write down the output of the given program. Show with dry run in table.
SEE 2074 (2018)DECLARE SUB Display (T$) CLS T$ = "COMPUTER" CALL Display (T$) END SUB Display (T$) FOR C = 1 TO LEN (T$) STEP 2 D$ = MID$ (T$, C, 1) PRINT D$; NEXT C END SUB
5. Write down the output of the given program. Show with dry run in table.
DECLARE SUB PATTERN() CALL PATTERN END SUB PATTERN A=2 FOR I = 1 TO 5 PRINT A; A=A+2 NEXT I END SUB
Answer:Dry Run:
A | FOR I= 1 to 5 | Print A; | A=A+2 |
2 | 1 | 2 | A=2+2=4 |
4 | 2 | 4 | A=4+2=6 |
6 | 3 | 6 | A=6+2=8 |
8 | 4 | 8 | A=8+2=10 |
10 | 5 | 10 | A=10+2=12 |
2 4 6 8 10
6. Write down the output of the given program. Show with dry run in table.
DECLARE SUB PATTERN()
CALL PATTERN
END
SUB PATTERN
FOR I = 1 TO 5
FOR J= 1 TO I
PRINT J;
NEXT J
PRINT
NEXT I
END SUB
Answer:Dry Run:-
I | J= 1 to I | Print J; |
1 | 1-1 | 1 |
2 | 1-2 | 12 |
3 | 1-3 | 123 |
4 | 1-4 | 1234 |
5 | 1-5 | 12345 |
7. Write down the output of the given program. Show with dry run in table.
DECLARE SUB RESULT()
CALL RESULT
END
SUB RESULT()
N=5
C=1
WHILE C<=5
PRINT N
N=N*10+5
C=C+1
WEND
END SUB
Answer:Dry Run:-
N | C | C<=5? | PRINT N | N=N*10+5 | C=C+1 |
5 | 1 | 1<=5? YES | 5 | N=5*10+5 =55 |
C=1+1=2 |
55 | 2 | 2<=5? YES | 55 | N=55*10+5 =555 |
C=2+1=3 |
555 | 3 | 3<=5? YES | 555 | N=555*10+5 =5555 |
C=3+1=4 |
5555 | 4 | 4<=5? YES | 5555 | N=5555*10+5=55555 | C=4+1=5 |
55555 | 5 | 5<=5? YES | 55555 | N=55555*10+5 =555555 |
C=5+1=6 |
8. Write down the output of the given program. Show with dry run in table.
DECLARE SUB SHOW (A)
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
Answer:Dry Run:- N=87
A=87
B= A MOD 6 + 3 | B MOD 4=0? | PRINT B; | A=A-10 | A>=50? |
B=87 MOD 6 + 3 =3+3=6 |
6 MOD 4 =0? (NO) | 6 | A=87-10=77 | 77>=50? Y |
B=77 MOD 6 + 3 =5+3=8 |
8 MOD 4=0? YES | – | A=77-10=67 | 67>=50? Y |
B=67 MOD 6 =1+3=4 |
4 MOD 4=0? YES | – | A=67-10=57 | 57>=50? Y |
B=57 MOD 6 = 3+3=6 |
6 MOD 4=0? NO | 6 | A=57-10=47 | 47>=50? NO |
6 6
9. Write down the output of the given program. Show with dry run in table.
DECLARE SUB 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
Answer:Dry Run:
N=135
A=135
A<>0? | R= N MOD 10 | T=T+R | A=A\10 | PRINT T |
135<>0? YES | R= 135 MOD 10=5 | T=0+5=5 | A=135\10=13 | - |
13<>0? YES | R=13 MOD 10=3 | T=5+3=8 | A=13\10=1 | - |
1<>0? YES | R= 1 MOD 10=1 | T=8+1=9 | A=0 | - |
0<>0? NO | - | - | - | 9 |
9
10.Write down the output of the given program. Show with dry run in table.
DECLARE SUB REMINDER (R)
CLS
FOR I = 1 TO 4
READ X
CALL REMINDER (X)
NEXT I
DATA 56,28,8,48
END
SUB REMINDER (R)
R1 = R MOD 4
R2 = R MOD 3
IF R1 = 0 AND R2<> 0 THEN
PRINT R
END IF
END SUB
Answer:Dry Run:
X | R | R1=R MOD 4 | R2=R MOD 3 | R1=0 AND R2<>0 | PRINT R |
56 | 56 | R1 = 0 | R2=2 | YES | 56 |
28 | 28 | R1=0 | R2=1 | YES | 28 |
8 | 8 | R1=0 | R2=2 | YES | 8 |
48 | 48 | R1=0 | R2=0 | NO | - |
56 28 8
11.Write down the output of the given program. Show with dry run in table.
DECLARE SUB show(abc$)
CLS
abc$ = "ZHTUOMENXSA"
CALL show(abc$)
END
SUB show(abc$)
Y = 48
FOR I = 1 TO 5
N = Y MOD 7
PRINT MID$(abc$,n,1);
Y = Y - 1
NEXT I
END SUB
Answer:Dry Run:
Y | I | N=Y MOD 7 | Print MID$(abc$,N,1); | Y=Y-1 |
---|---|---|---|---|
48 | 1 | 6 | M | 47 |
47 | 2 | 5 | O | 46 |
46 | 3 | 4 | U | 45 |
45 | 4 | 3 | T | 44 |
44 | 5 | 2 | H | 43 |
12.Write down the output of the given program. Show with dry run in table.
DECLARE SUB ABC()
CALL ABC
END
SUB ABC
N = 10
C = 1
D = 5
WHILE C<=5
PRINT N
N = N + D
C = C + 1
D = D + 5
WEND
END SUB
Answer:Dry Run:
N | C | WHILE N<=5? | Print N | N=N+D | C=C+1 | D=D+5 |
---|---|---|---|---|---|---|
10 | 1 | YES | 10 | 10+5=15 | 2 | 5+5=10 |
15 | 2 | YES | 15 | 15+10=25 | 3 | 10+5=15 |
25 | 3 | YES | 25 | 25+15=40 | 4 | 15+5=20 |
40 | 4 | YES | 40 | 40+20=60 | 5 | 20+5=25 |
60 | 5 | YES | 60 | 60+25=85 | 6 | - |
13.Write down the output of the given program. Show with dry run in table.
DECLARE SUB RESULT()
CALL result
END
SUB result ()
FOR I = 1 TO 4
FOR J = 1 TO 5
PRINT (I + J) * 10 ;
NEXT J
PRINT
NEXT I
END SUB
Answer:Dry Run:
Outer Loop | Inner Loop | OUTPUT |
---|---|---|
I | J | (I+J)*10 |
1 | 1-5 | (1+1)*10=20 (1+2)*10=30 (1+3)*10=40 (1+4)*10=50 (1+5)*10=60 |
2 | 1-5 | (2+1)*10=30 (2+2)*10=40 (2+3)*10=50 (2+4)*10=60 (2+5)*10=70 |
3 | 1-5 | (3+1)*10=40 (3+2)*10=50 (3+3)*10=60 (3+4)*10=70 (3+5)*10=80 |
4 | 1-5 | (4+1)*10=50 (4+2)*10=60 (4+3)*10=70 (4+4)*10=80 (4+5)*10=90 |
14. Write down the output of the given program. Show with dry run in table.
DECLARE FUNCTION NUMPRO(A AS INTEGER, B AS INTEGER)
DIM N, M, S AS INTEGER
CLS
DATA 2,5
READ M%,N%
S = NUMPRO(N%, M%)
PRINT "Sum of all the values is";S
END
FUNCTION NUMPRO(A AS INTEGER,B AS INTEGER)
S = 0
FOR C=1 TO A%
PRINT C*B%
S = S + C * B%
NEXT C
NUMPRO=S
END FUNCTION
Answer:Dry Run:
A=N=5
B=M=2
Counter Loop | OUTPUT | S |
---|---|---|
C | C*B% | S=S+C*B% |
1 | 1*2=2 | S=0+1*2=2 |
2 | 2*2=4 | S=2+2*2=6 |
3 | 3*2=6 | S=6+3*2=12 |
4 | 4*2=8 | S=12+4*2=20 |
5 | 5*2=10 | S=20+5*2=30 |
15. Write down the output of the given program. Show with dry run in table.
DECLARE SUB SUM(A,B,S)
DECLARE FUNCTION ADD(X,Y)
CLS
M=5 : N=10
A = ADD(M, N)
B = ADD(M, N)
CALL SUM(A,B,S)
PRINT "SUM=";S
END
SUB SUM(A,B,S)
S = A + B
END SUB
FUNCTION ADD(X,Y)
ADD = X + Y
END FUNCTION
Answer:Dry Run:
Here, M=5 and N=10 A=ADD(5,10)=15 B=ADD(5,10)=15 S=A+B=15+15=30 Note: For confirmation of value of A and B; you can use Print A,B before call statement.
∴Final output is: SUM=3016. Write down the output of the given program. Show with dry run in table.
DECLARE FUNCTION ESUM()
PRINT ESUM
END
FUNCTION ESUM()
FOR A = 2 TO 10 STEP 2
S = S + A
NEXT A
ESUM = S
END FUNCTION
Answer:Dry Run:
Counter Loop | SUM |
---|---|
A | S=S+A |
2 | S=0+2=2 |
4 | S=2+4=6 |
6 | S=6+6=12 |
8 | S=12+8=20 |
10 | S=20+10=30 |