0% found this document useful (0 votes)
2 views3 pages

Qbasic Editor

The document contains a series of QBasic programming examples and exercises, demonstrating user input, basic arithmetic operations, and graphical output. It includes code snippets for creating a simple interactive program, drawing a face, and calculating tips. Additionally, it provides practical exercises for users to practice loops and graphical commands.

Uploaded by

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

Qbasic Editor

The document contains a series of QBasic programming examples and exercises, demonstrating user input, basic arithmetic operations, and graphical output. It includes code snippets for creating a simple interactive program, drawing a face, and calculating tips. Additionally, it provides practical exercises for users to practice loops and graphical commands.

Uploaded by

Soumya Mukherjee
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

CLS

2 INPUT "What is your name"; name$


3 PRINT "Hello, "; name$; "!"
4 INPUT "How old are you"; age
5 INPUT "what is your best computer game?", game$
6 PRINT " name:"; name$
7 PRINT " age:"; age; " years old"
8 PRINT "best game:"; game$

PRINT "This line will be erased"


CLS
PRINT "Hello";
PRINT " World",
PRINT "Hello Jupiter"
PRINT "Good Bye",,"For";" Now"
PRINT 1,2,3,4,5

CLS
LOCATE 14, 34 'position the left eye
PRINT "<=>" 'draw the left eye
LOCATE 14, 43 'position the right eye
PRINT "<=>" 'draw the right eye
LOCATE 16, 39 'position the nose
PRINT "o|o" 'draw the nose
LOCATE 18, 36 'position the mouth
PRINT "\_______/" 'draw the mouth
LOCATE 19, 42 'the bottom
PRINT "The Face by QBasic"

CLS
LOCATE 14, 34
COLOR 9
PRINT "<=>"
LOCATE 14, 43
PRINT "<=>"
COLOR 11
LOCATE 16, 39
PRINT "o|o"
COLOR 4
LOCATE 18, 36
PRINT "\_______/"
COLOR 20
LOCATE 19, 42
PRINT "U"
LOCATE 1, 1
COLOR 16, 1
PRINT "Hello World"

CLS
'Set a-d to initial values
a = 10
b = 6
c = 3.1415
d = 3.333333
e = a + b
PRINT a; "+"; b; "="; e
f = c * d
PRINT c; "*"; d; "="; f
g = b - c
PRINT b; "-"; c; "="; g
h = b / d
PRINT b; "/"; d; "="; h
i = INT(d)
PRINT "Remove the decimal from "; d; "="; i

CLS
INPUT "Enter a number: ", x
PRINT
x = x + 5
PRINT "X is now: "; x
x = x * x
PRINT "X is now: "; x
x = x / 5
PRINT "X is now: "; x
x = x - 4
PRINT "X is now: "; x
x = x / x
PRINT "X should be 1: "; x
CLS
INPUT "How much is your bill: ", bill
INPUT "What percent tip do you want to give: ", tip
tip = tip / 100 'change percent to decimal
tip = tip * bill 'change decimal to money
PRINT
PRINT "The tip is"; tip; "$."
PRINT "Pay"; tip + bill; "$ total."

CLS CLS

SCREEN 9 SCREEN 9

CIRCLE (100, 100), 50, 9 CIRCLE (100, 100), 100, 9

LINE (100, 100) – (100, 20), 11 CIRCLE (100, 100), 80, 9

LINE (100, 100) – (100, 120), 11 CIRCLE (100, 100), 60, 9

LINE (100, 100) – (20, 100), 12 CIRCLE (100, 100), 40, 9

LINE (100, 100) – (120, 100), 12 CIRCLE (100, 100), 20, 9

BEEP BEEP

END END

PRACTICAL EXERCISES

1.
PRINT “Enter your name”
INPUT name$
FOR i = 1 TO 5
PRINT name$
NEXT i
END
2.
PRINT “Table of 5 is”
FOR i = 1 TO 10
PRINT “5 * ” ; i ; “= ” ; 5 * i
NEXT i
END
3.
PRINT “Odd numbers starting from 19”
FOR i = 19 TO 1 STEP –2
PRINT i
NEXT i
END
5.
4.
CLS
CLS
SCREEN 9
SCREEN 9
CIRCLE (100, 100), 50
LINE (10, 10) – (150, 60), 10, B
CIRCLE (100, 250), 50
LINE (10, 70) – (150, 120), 10, B
END
LINE (10, 130) – (150, 180), 10, B
END

You might also like