Beginner's Programming Tutorial in QBasic

(Kiana) #1

Variables


This chapter discusses an important topic in programming, "variables." Please read this section
thoroughly.
A variable is a piece of data kept in the computer's memory (RAM). The location of a variable in
RAM is called the "address."


How a variable is stored in RAM

The following program prints the variable X to the screen:
print X
Since the variable hasn't been assigned a number, the value of the variable is 0. So, the output ofthe program is:


0

This next program sets X to 15, and then prints the variable:
X = 15
print X
This time, the output is:
15

Free download pdf