Dashain and Tihar vaccation homework
1. Post 15 QBASIC Programming questions on blog.(Questions are given in copy)
2. Write the output of the following programs.
a) CLS
LET L = 13.5
LET B = 4.7
LET C = L*B
PRINT "Area of rectangle is ";C
OUTPUT
The area of rectangle is 63.45
b) CLS
LET A = 4/2
LET B = A+11-3
LET C =A^2-4
LET D = C MOD 6
PRINT D
END
OUTPUT
0
3. Correct the errors in the following programs.
a) CLS
LET A = 67
REM B = A/B
DISPLAY C
STOP
⇨ CLS
LET A =68
LET B = 8
LET C = A/B
PRINT C
END
b) CLS
ENTER L= 13
LET B = 4
LET C = L*B
PRINT "Area of rectangle is "; A
END
⇨CLS
LET L = 13
LET B = 4
LET C = L*B
PRINT " Area of rectangular is "; A
END
c) CLS
CONSTANT pi = 22/7
LET r = 13
LET h = 4
a = pi * r ^ 2
END
⇨ CLS
CONSTANT pi =22/2
LET r =13
LET h = 4
a = pi * r ^ 2
END
⇨ CLS
CONST pi = 22/2
LET r = 13
LET h = 4
a = pi * r ^ 2
PRINT a
END
2. Write the output of the following programs.
a) CLS
LET m = 37
IF m > 40 THEN
PRINT "Result pass"
ELSE
PRINT "Result fail"
END IF
END
OUTPUT
RESULT FAIL
b) CLS
LET A = 15
LET B = 3
IF A > B THEN
PRINT A + B
ELSE
PRINT A / B
END IF
END
OUTPUT
18
c) CLS
B = 20
WHILE B> = 2
PRINT B
B = B -2
WEND
END
OUTPUT
20
18
16
14
12
10
8
6
4
2
d) CLS
FOR K = 1 TO 5
PRINT K^ 2
NEXT K
END
OUTPUT
1
4
9
16
25
3.Correct the errors in the following programs.
a)REM TO CHECK RESULT PASS OR FAIL
CLS
INPUT "Enter the marks ";M
IF m>40 THEN
PRINT "Result pass"
OR
DISPLAY "Result fail "
STOP IF
END
⇨ CLS
INPUT "Enter the marks";m
IF m > = 40 THEN
PRINT "Result pass"
ELSE
PRINT "Result fail"
END IF
END
b) CLS
FOR K= 2 TO 10
PRINT K
NEXT C
STOP
⇒ CLS
FOR K = 2 TO 10 STEP 2
PRINT K
NEXT K
END
c) CLS
B = 3
WHILE B>=21
PRINT B
B=B+1
END
NEXT B
⇒CLS
B=3
WHILE B<=21
PRINT B
B=B+2
WEND
END
d) CLEAR
n=500
DO WHILE n>50
PRINT n
n=n+50
WEND
END
⇒CLS
n = 500
DO WHILE n >= 50
PRINT n
n =n-50
LOOP
END
2. Write the output of the following programs.
a) CLS
LET L = 13.5
LET B = 4.7
LET C = L*B
PRINT "Area of rectangle is ";C
OUTPUT
The area of rectangle is 63.45
b) CLS
LET A = 4/2
LET B = A+11-3
LET C =A^2-4
LET D = C MOD 6
PRINT D
END
OUTPUT
0
3. Correct the errors in the following programs.
a) CLS
LET A = 67
REM B = A/B
DISPLAY C
STOP
⇨ CLS
LET A =68
LET B = 8
LET C = A/B
PRINT C
END
b) CLS
ENTER L= 13
LET B = 4
LET C = L*B
PRINT "Area of rectangle is "; A
END
⇨CLS
LET L = 13
LET B = 4
LET C = L*B
PRINT " Area of rectangular is "; A
END
c) CLS
CONSTANT pi = 22/7
LET r = 13
LET h = 4
a = pi * r ^ 2
END
⇨ CLS
CONSTANT pi =22/2
LET r =13
LET h = 4
a = pi * r ^ 2
END
⇨ CLS
CONST pi = 22/2
LET r = 13
LET h = 4
a = pi * r ^ 2
PRINT a
END
2. Write the output of the following programs.
a) CLS
LET m = 37
IF m > 40 THEN
PRINT "Result pass"
ELSE
PRINT "Result fail"
END IF
END
OUTPUT
RESULT FAIL
b) CLS
LET A = 15
LET B = 3
IF A > B THEN
PRINT A + B
ELSE
PRINT A / B
END IF
END
OUTPUT
18
c) CLS
B = 20
WHILE B> = 2
PRINT B
B = B -2
WEND
END
OUTPUT
20
18
16
14
12
10
8
6
4
2
d) CLS
FOR K = 1 TO 5
PRINT K^ 2
NEXT K
END
OUTPUT
1
4
9
16
25
3.Correct the errors in the following programs.
a)REM TO CHECK RESULT PASS OR FAIL
CLS
INPUT "Enter the marks ";M
IF m>40 THEN
PRINT "Result pass"
OR
DISPLAY "Result fail "
STOP IF
END
⇨ CLS
INPUT "Enter the marks";m
IF m > = 40 THEN
PRINT "Result pass"
ELSE
PRINT "Result fail"
END IF
END
b) CLS
FOR K= 2 TO 10
PRINT K
NEXT C
STOP
⇒ CLS
FOR K = 2 TO 10 STEP 2
PRINT K
NEXT K
END
c) CLS
B = 3
WHILE B>=21
PRINT B
B=B+1
END
NEXT B
⇒CLS
B=3
WHILE B<=21
PRINT B
B=B+2
WEND
END
d) CLEAR
n=500
DO WHILE n>50
PRINT n
n=n+50
WEND
END
⇒CLS
n = 500
DO WHILE n >= 50
PRINT n
n =n-50
LOOP
END
Comments
Post a Comment