Chapter 7 - Qbasic Tutorial - Qbasic Tutorial - Qbasic Tutorial - ^^JPS^^
Saturday, 2016-12-03, 5:37 PM

Welcome Guest | RSS

Qbasic Home

Catalog categories
Qbasic Tutorial [31]

Rate my Site
Rate JPSor Site
Total of answers: 149

Main » Articles » Qbasic Tutorial

Chapter 7 - Qbasic Tutorial
Operations in Math
        Since we are going to perform some computations, let us recall the basic operation, operators, and aperands.
        The table below discusses the operators, the symbols used, some examples and their results.
Operator (symbol used in the computer)
1.       Addition
45 + 8
2.       Subtraction
137 – 25
3.       Multiplication
34 * 87
4.       Division
75 / 3
5.       Integer Division
64 \ 3
6.       Remainder after Division
8 MOD 3
7.       Exponentiation
3 ^ 2
         Instead of an x for multiplication, the computer uses the asterisk(*) symbol. This is found on the top of the number 8 key in the keyboard. Just press the SHIFT button plus the number 8 key. The ramainder after division is also called modular division. When making calculations using modular division, just type the three letters MOD. For the exponentiation, look for the caret(^) sign found on the top of the number 6 key in the keyboard. Same with the asterisk, just press SHIFT together with the number 6 key.
Order of Operation
        The Computer also follows the left to Right rule and PEMDAS rule in math when evaluating arithmetic expressions. PEMDAS means Parenthesis, Exponent, Multiplication, Division, Addition, and Subtraction.
        The table below shows the priority of the operation. The highest priority is what comes first.


Operator (symbol used in the computer)

1.       Exponent


2.       Multiplication, Division

*(asterisk), /

3.       Integer Division


4.       Modular (remainder after division)


5.       Addition, Subtraction

+, -

Computers are very good at math. Let's get the computer to do some math for us. Here's a simple multiplication calculator:
INPUT "Enter the first number: ", A
INPUT "Enter the second number: ", B
PRINT "The answer is: "; A * B

If you have trouble finding the star (or asterisk "*") on the keyboard, it is usually above the number 8. Run it, and enter two numbers. It does an excellent job multiplying for you.

Variables and Math

A and B are variables, just like Name$. Unlike Name$, A and B do not have a dollar-sign after their names. This is because they are only holding numbers, not letters.


"A * B" means "A times B". QBASIC doesn't use "X" for multiplication because you might want to have a variable called "X".

What else?

Try changing the "A * B" to "A - B" for subtraction. "A + B" will do addition, and "A / B" will do division. Why "/" for division? Because there's no division sign key on the keyboard. At least I haven't found one.


"A * B", "A + B", "A - B", and "A / B" are called mathematical expressions, or simply "expressions".


  • Variables with numbers
  • INPUT with numbers
  • Multiplication, Division, Addition, Subtraction
  • Expressions

Category: Qbasic Tutorial | Added by: JPSor (2009-02-26) | Author: JPSor
Views: 3501 | Rating: 4.0/3 |

Qbasic Clock


Visit my Friends

Who's Online

Total online: 1
Guests: 1
Resgistered: 0

Copyright MyCorp © 2016