The Rogue's
TI-86 BASIC Tutorial
Chapter 3: Math and Variables

You will now learn how to do math in a program and how to manipulate variables. Mathematical operations may be entered into a program exactly how they would on the home screen. The only difference is that on the home screen the answer to the problem is displayed automatically and in a program it is not. So, you need variables to hold the answers for you...

Say you want to set a variable equal to a number. You would use the -> operator (In this tutorial, -> is the key labeled [STO->]). For example, to store the value 45 to variable A, you would enter this:


A less commonly used method of storing a value to a variable is with the "=" operator. The code


does pretty much the same thing as in the previous example, except that it makes A an "equation variable" (Which can be used in the equation solver) instead of a "real variable". You will be using the store method more often. Now make a new program called "ADDER". Enter this code:

:Input "First Number: ",A
:Input "Second Number: ",B
:Disp "Adding your numbers.."
:Disp C

ADDER lets the user enter two numbers which are stored to variables A and B. The screen is cleared, and "Adding your numbers.." is displayed. The program then solves the equation A+B and stores the answer to C. Isn't that simple? Now the contents of variable C (The sum of A and B) are displayed. That's all there is to doing math in programs.

Now create a new program entitled "CUBER". This baby will let the user enter a number, cube it, and display the result. Here is one way to write the program:

:Input "Enter a number: ",A
:Disp A^3

This program clears the screen, lets the user enter a number, clears the screen again, and finally displays variable A after it is cubed. Notice something about what just happened here: Variable A holds the original number. The command ":Disp A^3" does not alter the number stored in variable A at all. It only displays what A would be after being cubed. Say you want A to be cubed before you display it. Clear out the old code and enter this:

:Input "Type a number: ",A
:Disp A

Instead of displaying what A would be equal to, the calculator actually stores the cube of A. Now A has been changed from the original.

Practice Program: Quadratic Equation Solver 1.0 - Practice the skills you learned in this chapter

Excellent, now on to Chapter 4: Basic Control.

Click to Return to This Tutorial's Home Page