Hila Research Centre
Computer Programming - 3
Doing Math in Qbasic:
Try this:
PRINT 8 + 12
Qbasic handles all math functions, be careful with the order you do things in.
PRINT (134 + 589)/45
Variables:
Variables are a very important and powerful part of programming. A variable is a
word or letter that represents a place where Qbasic keeps some information for you.
Try this:
a = 1
PRINT a
When you typed in "a = 1", Qbasic stored the number 1 in memory and you told it to call
this place "a" ( "a" is the variable). When you typed in "PRINT a", your computer
displayed the number that was stored at "a" and this was the number 1.
Input:
This is a very handy command that allows the computer user to store numbers or words
as variables.
Try this.
INPUT "Enter a number",n
INPUT "Enter a number",x
CLS
PRINT "The first number is";n
PRINT "The second number is";x
The program stores any number you enter as the variables "n" and "x".