QBASIC Element
Elements Of QBASIC Programming
- QBASIC character set
- Variable
- Constant
- Operator and Expression
- Keywords (Reserved words)
QBASIC character set
Character set is set of valid character that a language can recognize. A character represents any letter, digits or any other sign. The QBASIC has the following character set:
- Alphabets : A to Z (small and capital letters)
- Numbers : 0 to 9
- Special Character : ;=+*/^()%$#!,.":&?<>
Variable
Variables are the storage locations in the computer's memory for storing data. It is referred to by a name and whose value can be altered during program execution. The variable names have the following properties:
- Any variable name may be up to 40 character long.
- Variable names must begin with a letter (A to Z, a to z).
- variables names cannot contain character other than letters, numbers, period, and the type of declaration characters ($, %, #, & and !)
- Variables names cannot be QBASIC reserved words.
- Variables may represent either numeric values or strings.
- Variable name cannot begin with "FN" unless it is a function call.
Numerical Variable
A numeric variable has a number as its value. It must begin with an alphabet and the remaining character, if used, may be alphabets or digits or both. Some of the valid numerical variables are d2, volume and area1.
String Variable
A string variable represent numbers, alphabets and special character. this variable should:
- Begin with alphabet.
- Must end with dollar sign ($).
- Can be more than one character and numbers but no special character is allowed.
Constant
Constant is a value stored in a program which does not change during program execution. Based on the type of data, it is classified as numeric constant and string constant.
Numeric Constant
Numeric constant is a numeric value on which mathematical operations such as addition, subtraction, multiplication and division can be performed. It consists of a sequence of digits (0-9) with or without decimal points. It can be a positive or a negative number. some of the valid numeric constants are 12, -10, +54 and 19.
String Constant
String constant is set of alphanumeric or special characters enclosed within double quotes. Blank space can also be used in a string. These types of data cannot be used for mathematical calculations but can be used for comparisons and references. Some of the valid string constants are "Computer Zone" and "Computer World".
Operator and Expression
An operator is a symbol representing the operation they perform on operands in a program. The value on which the operators work is referred to as operands.
An expression is a programming statement that has a value. It is composed of operators and operands. An operand may be a variable or a constant. An expression indicates one or more operations to be carried out in specific order.

Comments
Post a Comment