(IX) QBASIC Output Practice Questions


1. Write down the output of the given program. Show with dry run in table.

CLS A=100 B=50 PRODUCT =A*B PRINT "Product of two numbers is ";PRODUCT END
Answer:
Dry Run :
A=100,B=50
PRODUCT=A*B=100*50=5000
Product of two numbers is 5000
∴ Final Output is
Product of two numbers is 5000

2. Write down the output of the given program. Show with dry run in table.

CLS P=1000 T=10 R=30 I=(P*T*R)/100 PRINT "Simple Interest is "; I END
Answer:
Dry Run :
P=1000,T=10,R=30
I=(P*T*R)/100=(1000*10*30)/100=3000
Simple Interest is 3000
∴ Final Output is
Simple Interest is 3000

3. Write down the output of the given program. Show with dry run in table.

CLS LET A=10 LET B=5 LET C=3 AV=(A+B+C)/3 PRINT "Average of three numbers is "; AV END

Answer:
Dry Run :
A=10,B=5,C=3
AV=(A+B+C)/3=(10+5+3)/3=18/3=6
Average of three numbers is 6
∴ Final Output is
Average of three numbers is 6

4. Write down the output of the given program. Show with dry run in table.

CLS FOR P = 1 TO 5 PRINT P^2; NEXT P END
Answer
Dry Run
Variable Print (Output
P P^2;
1 1^2=1
2 2^2=4
3 3^2=9
4 4^2=16
5 5^2=25
∴ Final Output is
1 4 9 16 25

5. Write down the output of the given program. Show with dry run in table.

CLS FOR P = 1 TO 5 FOR L = 1 TO P PRINT L; NEXT L PRINT NEXT P END

Answer:
Dry Run:
Variable (P) Variable (L)= 1 to P Output L;
1 1-1 1
2 1-2 1 2
3 1-3 1 2 3
4 1-4 1 2 3 4
5 1-5 1 2 3 4 5
∴Final Output is: 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5

6. Write down the output of the given program. Show with dry run in table.

CLS N$= "SCIENCE" P=1 L=7 K=5 FOR I = 1 TO LEN(N$) STEP +2 PRINT TAB(K);MID$(N$,P,L) P=P+1 L=L-2 K=K+1 NEXT I END
Answer
Dry Run
P L K I Output:MID$(N$,P,L)
1 7 5 1 MID$(“SCIENCE”,1,7)=SCIENCE
2 5 6 3 MID$(“SCIENCE”,2,5)=CIENC
3 3 7 5 MID$(“SCIENCE”,3,3)=IEN
4 1 8 7 MID$(“SCIENCE”,4,1)=E
∴Final Output is
SCIENCE CIENC IEN E