Tutorial Two - Doing your Math homework. . .the easy way
As you learned in the first tutorial, BASIC-256 can print messages on the screen. It can be fun to make the computer say what you want it to, but it's not really useful. Do you know what the first computers were built to do? That's right, they were made to do math. And they do it really quickly. Let's see how we can make the computer do math for us.
print 1 + 1
If you run the program, you'll see how the computer prints out 2, the correct answer. Notice how we don't put the numbers in quotation marks. Quotation marks are only used for messages. Let's see what happens if we use quotation marks anyway:
print 1 + 1 print "1 + 1"
Hey! The computer printed out 2, then "1 + 1", without adding the numbers together. Now we can see what the quotation marks do. They tell the computer to print exactly what is inside, without doing any math. So, if you want the computer to do math, don't use the quotes. Otherwise, make sure to put them in.
How about more complicated math? BASIC-256 can do that too. Try typing in these lines and see what happens:
print 1 + 2 + 3 print 3 - 2 print 2 * 2 print 4 / 2
There we go, addition, subtraction, multiplication, and division. Now, go ahead and try some math problems of your own.
Congratulations! You've finished the second tutorial. By now, you should understand:
- How to add, subtract, multipy, and divide with BASIC-256
- When to use quotation marks with the PRINT command