0% found this document useful (0 votes)
10 views6 pages

QBASIC Output Questions (21-12-2024)

The document contains a series of QBASIC output questions designed for practice, authored by Sir Subhendu. Each question includes code snippets that involve various programming constructs such as loops, conditionals, and arithmetic operations, followed by an answer key providing the expected outputs for each question. The questions range in complexity and cover different aspects of QBASIC programming.

Uploaded by

rak246463
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views6 pages

QBASIC Output Questions (21-12-2024)

The document contains a series of QBASIC output questions designed for practice, authored by Sir Subhendu. Each question includes code snippets that involve various programming constructs such as loops, conditionals, and arithmetic operations, followed by an answer key providing the expected outputs for each question. The questions range in complexity and cover different aspects of QBASIC programming.

Uploaded by

rak246463
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

QBASIC Output Questions (for practice)

By Sir. Subhendu

Q. No. Questions
1. x = 17846
While (x > 9)
y = x Mod 10
z=z-y
If (z < -20) Then
Exit While
End If
x = x / 10
Wend
Print z;
2. For i = 1 To 5
j=j+i
ch = j Mod 10
Select Case ch
Case 0
k=k+i
Case 2
k = k - 10
Case 5
k=k*2
Case Else
k = k + (j Mod 10) + i
End Select
Next i
Print k;
3. a = 42
b = -a
c=a+b
If (c > 0) Then
For i = 1 To 3
s=s+c
Next i
End If
If (b <> 0) Then
c=c+b
If (c > b) Then
If (c Mod 2 = 0) Then
While (a <> 0)
s = s + a Mod 10
a = a \ 10
Wend
Else
While (b <> 0)
s = s - b Mod 10
b = b \ 10
QBASIC Output Questions (for practice)
By Sir. Subhendu

Wend
End If
c = c + 10
End If
End If
Print c + a + b + s;

4. hp = -43
dell = hp Mod 10 + (123 \ 10)
mac = hp + dell \ 10
lenovo = mac
While (lenovo <> 0)
d = lenovo Mod 10
If (d Mod 2 = 0) Then
dell = dell + d
Else
hp = hp - 1
End If
lenovo = lenovo \ 10
Wend
If (mac Mod 2 = 0) Then
mac = -mac + hp
End If
Print lenovo; mac; hp; dell

5. num = 1706
While (num > 9)
c=0
For k = num Mod 10 To 0 Step -1
c=c+1
sum = sum + k
If (c > 2) Then
Exit For
End If
Next k
num = num \ 10
Wend
Print sum;
6. For m = 0 To 3
x=x-m*2
For p = m To -1 Step -1
If (x Mod 2 = 0) Then
x=x+1
Else
x=x+p
End If
QBASIC Output Questions (for practice)
By Sir. Subhendu

Next p
Next m
Print x;
7. While (a > -99)
ch = a Mod 2
Select Case ch
Case 0
For i = 1 To 4
a=a-i
Next i
Case Else
For j = 8 To 10 Step 2
a=a-j
Next j
End Select
Print a;
a=a-1
Wend

8. x = 87123
For m = 0 To 2
For n = m To 0 Step -1
x = x \ 10
y = y + (x Mod 10) * 2
Next n
If (x < 1) Then
Exit For
End If
Next m
Print y;
9. val1 = -715
val2 = val1 Mod 100
If (val1 Mod 2 > 0) Then
Print "Hello"; val3
End If
val3 = val1 + 2
For k = 1 To 3
val1 = val2 + k
If (val1 > val3) Then
Exit For
End If
Next k
If (val1 <> val2 Or val2 Mod 2 = 0) Then
Print "QB"; val2; val3
Else
Print "JV"; val1; -val2
QBASIC Output Questions (for practice)
By Sir. Subhendu

End If
Print val1; ","; val2; val3
10. yes = 123
no = 74
why = yes \ 10 + no \ 5
okay = (yes + no) \ 10
alright = (why - okay) \ 10
Print yes + no;
Print no; why;
For k = 3 To 0 Step -2
yes = yes + k
alright = alright + 1
okay = -okay
Exit For
Next k
Print yes; no; why + okay; alright;
11. For a = 10 To 0 Step -5
For b = 5 To 10 Step 5
For c = a + b To 100 Step 1
Print "Hello"; c
Exit For
Next c
Print "Hi"; b + a
Exit For
Next b
Next a
12. keyboard = 100
game = keyboard \ 10
keyboard = keys \ keyboard
mouse = keyboard - game
game = mouse + 100
If (keyboard = 100) Then
Print "Happy"; game
If (mouse < 1000) Then
mouse = 1000
End If
Else
For java = 1 To 4 Step 2
game = game + java
Next java
End If
Print game; "why?"; mouse + keyboard
If (keys Mod 2 = 0) Then
keys = keys * 10
End If
Print keys; game;
QBASIC Output Questions (for practice)
By Sir. Subhendu

13. a = 7428
While (a > 0)
b = a Mod 100
While (b > 0)
c=c-b
b = b \ 10
Wend
a = a \ 10
If (a < 10) Then
Exit While
End If
Print c;
Wend
Print -c;
14. a=2
b = a + (-a * 2)
c = (a + b) Mod 5
d = a Mod 100
Print a + b + c + d;
While (x > -10)
a=a+5
b = b + x Mod 10
c=a
x=x-5
Wend
Print a + b + c + d;
For y = 3 To 5 Step 2
If (y Mod 2 = 0) Then
a=0
Exit For
End If
Exit For
Next y
Print a + b + c - d;
15. For x = 101 To 0 Step -51
If (x Mod 50 = 0) Then
For y = 1 To 3
p=p+y
Next y
Print "Hi"; p
Else
y = 123
While (y > 0)
p=p+y
y=0
QBASIC Output Questions (for practice)
By Sir. Subhendu

Wend
End If
Next x
Print p;

Answer key:
1. -27
2. 40
3. -42
4. 0 -43 -44 5
5. 33
6. -6
7. -10 -29 -40 -59 -70 -89 -100
8. 36
9. QB-15 -713
-14, -15, -713
10. 197 74 26 126 74 7 1
11. Hello 15
Hi 15
Hello 10
Hi 10
Hello 5
Hi 5
12. 94 Why? -10
0 94
13. -30 -76 157
14. 2 19 15
15. Hi 129
129

You might also like