Qbasic Tutorial for beginners and children (Under Construction)


How to use the memory in BASIC?

Remember! Data are store in memory variables or constants. In Qbasic variables should respect the following rules:

  • The length should not be greater than 40 characters
  • They should start with a letter
  • They should not contain spaces
  • They do not support certain characters such as (

If you don't put a suffix, BASIC considers the variable as being of single-precision type

The table below shows the different types of variables:

Data Types Suffix
Single-precision  !
Integer %
Double-precision #
Long-integer &

String

$

  • The first 4 types are used to store numbers. 
    • The Single-precision & double-precision types store floating numbers.
    • The integer & long-integer types store integers (numbers without decimal points).
  • The String variables store characters, letters, texts, sentences.

Examples:

Code Remark
a% = 10 Assigns the value 10 to variable a%.
message$ = "Hello friend" Stores the text "Hello friend" in the memory variable message$.

number1 = 10

number2 = 15

sum = number1 + number2

Assigns 10 to variable number1.

Assigns 15 to variable number2.

Assigns 25 to variable sum.

b% = 4.5 In this case BASIC will truncate the decimal part of the number and store only 4 in the memory. Note:- Though this is a mistake, BASIC won't generate an error message. 
c! = 10.123 Single-precision variables are used to store floating points.
c = 10.123

 

Same as above. When a variable has no suffix, it is considered as being a single-precision variable.

 

[ Previous Index Next ]


pages viewed since January  19 2002