- Get link
- X
- Other Apps
Recent - Posts
- Get link
- X
- Other Apps
Hello future programmers! 👋
Welcome to Post 4 of our QBasic learning series. In the previous lesson, we learned about variables and data types. Today, we’ll learn how to work with those variables using operators.
Simply put, operators tell the computer what to do with numbers and values—like adding, comparing, or making decisions.
What is an Operator?
An operator is a symbol that performs an action on data.
Example from daily life:
-
+means add -
-means subtract -
=means equal
In QBasic, operators help us:
-
Do calculations
-
Compare values
-
Combine conditions
-
Make decisions
Types of Operators in QBasic
QBasic mainly uses four types of operators:
-
Arithmetic Operators
-
Relational Operators
-
Logical Operators
-
String Operators
Let’s understand them one by one 👇
1. Arithmetic Operators
Used for mathematical calculations.
| Operator | Meaning | Example |
|---|---|---|
+ | Addition | a + b |
- | Subtraction | a - b |
* | Multiplication | a * b |
/ | Division | a / b |
\ | Integer Division | a \ b |
MOD | Remainder | a MOD b |
Example Program:
CLS a = 15 b = 4 PRINT "Addition: "; a + b PRINT "Subtraction: "; a - b PRINT "Multiplication: "; a * b PRINT "Division: "; a / b PRINT "Remainder: "; a MOD b
📝 Note:
-
MODgives the remainder. -
/gives decimal answers. -
\gives only whole numbers.
2. Relational Operators
Used to compare two values. The result is either TRUE or FALSE.
| Operator | Meaning |
|---|---|
= | Equal to |
<> | Not equal to |
< | Less than |
> | Greater than |
<= | Less than or equal |
>= | Greater than or equal |
Example:
CLS x = 10 y = 20 PRINT x < y PRINT x = y PRINT x <> y
These operators are very important for decision-making programs.
3. Logical Operators
Used to combine conditions.
| Operator | Meaning |
|---|---|
AND | Both conditions must be true |
OR | Any one condition true |
NOT | Reverses the condition |
Example:
CLS age = 18 PRINT age >= 16 AND age <= 25
✔ This will print TRUE if the age is between 16 and 25.
4. String Operators
Used with text (STRING) values.
Concatenation Operator (+)
Used to join strings.
CLS first$ = "Hello " second$ = "World" PRINT first$ + second$
📌 Output:
Hello World
Why Operators Are Important
-
Without operators, programs cannot calculate or compare.
-
They help in decision making, loops, and real-life logic.
-
Almost every program uses operators.
Key Points to Remember
-
Operators perform actions on data.
-
Arithmetic operators do calculations.
-
Relational operators compare values.
-
Logical operators combine conditions.
-
String operators join text.
What’s Next?
In Post 5, we’ll learn about IF…THEN…ELSE statements, where operators will help the computer make decisions just like humans do 🤯
Until then—practice small programs, try changing values, and see what happens.
That’s how real learning happens 🚀
Coding for Beginners
Computer Science for Students
Programming Basics
QBasic
QBasic Operators
SEE Computer
- Get link
- X
- Other Apps
Comments