QBasic Tutorial 2 - Printing Math - QB64


In Tutorial 1, we saw that PRINT was capable of printing text surrounded by quotes. PRINT is capable of doing a bit more. PRINT is capable of printing calculations too.


Notes:


QBasic follows the math rule of PEMDAS Please Excuse My Dear Aunt Sally. PEMDAS is also called the Order Of Operations.


Parentheses
Exponents
Multiplication
Division
Addition
Subtraction


Have a little fun. Check out the cheer for PEMDAS from some smart cheerleaders:


Video: Cheer for the Order of Operations (1:29)
























SQR is the square root function.

ABS is the absolute function.




In a new file, type and run the following:


CLS

PRINT 5 + 10

PRINT 6 - 5

PRINT 7 * 6

PRINT 10 / 2

PRINT 2 ^ 3

PRINT SQR(25)

PRINT ABS(-5)

PRINT 5 * 2 + 10

PRINT (5 * 2) + 10

PRINT 5 * (2 + 10)


Run the program and the output will be:


15

1

42

5

8

5

5

20

20

60



Code Download:  QBT2.BAS


Somethings to try on your own:


Make a program that will calculate your own math problems




Video Tutorial: QBasic Tutorial 2 - Printing Math - QB64


Previous Tutorial                  Next Tutorial