07.05.2015 Views

Bronze Edition Guide - True BASIC

Bronze Edition Guide - True BASIC

Bronze Edition Guide - True BASIC

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

33<br />

CHAPTER<br />

Constants, Variables and Expressions 6<br />

<strong>True</strong> <strong>BASIC</strong> lets you work with two kinds of information — numbers and strings. By definition,<br />

strings are any combination of characters. Examples of string data include names,<br />

addresses, or phone numbers. Let’s look first at numbers in <strong>True</strong> <strong>BASIC</strong> programs.<br />

When you use numbers in a <strong>True</strong> <strong>BASIC</strong> program, they may be constants, variables, or<br />

expressions (expression is just another name for formula). Look again at the simple MPG<br />

program that you created earlier:<br />

! Compute miles per gallon<br />

!<br />

LET miles = 420<br />

LET gallons = 14.3<br />

PRINT miles, gallons, miles/gallons<br />

END<br />

! miles traveled<br />

! gas used<br />

Constants<br />

The MPG program contains two numbers: 420 and 14.3. These are called constants or<br />

numeric constants.<br />

———————————————————————————————————————<br />

x Constants are quantities whose values can’t change during a program run.<br />

———————————————————————————————————————<br />

You can write constants as whole numbers, such as 420, or as decimals such as 14.3<br />

Note, however, that you can’t include any spaces or commas in numbers in <strong>True</strong> <strong>BASIC</strong>.<br />

Thus 10,000 must be written as 10000.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!