Qbasic example programs output with dry run in table.
Write down the output of the given program. Show with dry run in table.
Dry Run:
| FOR K= 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.
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.
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.
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.
Dry Run:
N=135
A=135
| A<>0? | R= A 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.
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.
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.
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.
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.
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 |
Netra Koirala
Computer Science Educator
Passionate computer science educator and author. Provides free study notes, practical guides, and tutorials for Class 9, 10, 11, 12, and B.Sc CSIT students in Nepal. Years of teaching experience in computer science fundamentals.
LinkedIn ProfileRelated Posts
Loading related posts…
Computer Science notes, tutorials, MCQs, and educational resources for Nepal students. Covering Class 9, SEE preparation, Class 11, Class 12, SLC, programming, DBMS, networking, HTML, JavaScript, PHP, OOP and more.
Featured Post
Grade 10 Computer Science: Specification Grid & Model Questions
Specification Grid & Model Questions of Computer Science | Grade 10 📚 Examination Resource Specification Grid & M...