What is an Operator in QBASIC?
An operator in QBASIC is a symbol that performs an operation on one or more values or variables. Operator help in making calculations, comparisons, and logical decisions in your program. Qbasic supports different types of operators which are explained below.
Types of Operator
1. Arithmetic Operator
Arithmetic operators are used to perform arithmetic operations such as addition, subtraction, division, multiplication etc.
| Operators | Operations | Examples |
| + | Addition | A+B |
| – | Subtraction | A-B |
| * | Multiplication | A*B |
| ^ | Exponential | A^2 |
| / | Division(Floating point) | A/B |
| \ | Division(Integer) | A\B |
| MOD | Modulus Division | A%B |
| – | Negation | Negation |
Operations within parenthesis are performed first.
2. Relational Operator
Relational operators are used to compare two values. The result is either True or False. The relational operators used in Qbasic are follow.
| Operator | Name | Example |
| = | Equal | A=B |
| < | Less than | A<B |
| > | Greater than | A>B |
| <= | Less than equal to | A<=B |
| >= | Greater than equal to | A>=B |
| <> | Not equal to | A<>B |
3. logical operator
Logical operators are used to combine multiple conditions and return a Ture or False value to be used in a decision. The logical operator used in Qbasic are described below:
| Operator | Name | Example | Explaination |
| AND | Conjunction | A>B AND A>C | True if both conditions are true |
| OR | Disjunction | A>B OR A>C | True if any one condition is true |
| NOT | Negation | NOT A = B | Reverses the result of the condition |
4. String / Concatenation Operator
Joining of two or more string is called concatenating of string. This can be done by using the sign plus(+).
A$ = "Computer"
B$ = "Kite"
C$ = A$ + B$
PRINT C$
END