Operators are the symbols, which refers to a specific operation. In the program operators are used to perform arithmetic and logical operations. For e.g '+' is a operator which adds any two numbers. The operator works between two or more than two values and gives result.
The following types of operators are used in QBASIC.
1. Arithmetic Operators
The operators which are used to perform different types of mathematical calculations such as addition, subtraction, multiplication and division are known as arithmetic operator.
Operator | Meaning |
+ | Addition |
- | Subtraction |
* | Multiplication |
/ | Division |
\ | Integer Division (10\4=2) |
MOD | Modulus Division : (10 MOD 3 = 1) |
^ | Exponent : (5^3=125) |
2. Relational or Comparison Operators
The operators which are used to compare two values are called relational or comparison operators. The relational operators used in QBASIC are as follows.
Operator Symbol | Relstion |
= | Equal to |
<> | Not equal to |
> | Greater than |
< | Less than |
>= | Greater than or equal to |
<= | Less than or equal to |
3. Logical Operator
The operators which are used to combine two or more relational expressions are called logical operators. It gives two logical value "True" or "False". The logical operators used in QBASIC are as follows:
AND |
OR |
NOT |
AND
AND operator gives 'true' result, only when all the input are 'true'. The AND truth table is given below.
X | Y | Result |
T | T | T |
T | F | F |
F | T | F |
F | F | F |
OR
OR operator gives 'true',when any one or all inputs are 'true'. The OR truth table is given below.
X | Y | Result |
T | T | T |
T | F | T |
F | T | T |
F | F | F |
NOT
NOT Operators on one operand and return 'True' if the logical operation returns 'False'. The NOT truth table is given below.
X | Result |
T | F |
F | T |
4. String Operator
String operator joins two or more strings. This process es called concatenation. The '+' sign is used as the String operator.
Example:
CLS x$ = "Technical" y$ = "School" PRINT x$ + y$ END |
Output
Technical School |