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.

96 BRONZE <strong>Edition</strong> <strong>Guide</strong><br />

The program will print the items in reverse order:<br />

You have these items:<br />

pliers 2<br />

bags of salt 4<br />

wood stoves 1<br />

umbrellas 2<br />

hammers 4<br />

Array Bounds<br />

In the INVNTORY program, item$ and number both have five elements, numbered from 1<br />

to 5. In <strong>True</strong> <strong>BASIC</strong>, however, you can use any numbers as the lower bound and upper<br />

bound for the array. That is, instead of having a lower bound of 1, the array could have a<br />

lower bound of 1991. Instead of having an upper bound of 5, you might use 1995. You still<br />

have an array with five elements, but with different bounds.<br />

You may want to adjust array bounds to make a particular problem easier to solve. The following<br />

program shows how you could read and compare census figures for a couple of towns:<br />

! View census figures<br />

!<br />

DIM springfield(1985 to 1990), woodsville(1985 to 1990)<br />

FOR y = 1985 to 1990<br />

READ springfield(y), woodsville(y)<br />

NEXT y<br />

INPUT PROMPT “What year are you interested in? “: year<br />

IF springfield(year) > woodsville(year) then<br />

LET town$ = “Springfield”<br />

ELSE<br />

LET town$ = “Woodsville”<br />

END IF<br />

PRINT “In”; year; town$; “ had the largest population.”<br />

DATA 17635, 16413, 17986, 16920, 18022, 17489<br />

DATA 18130, 17983, 18212, 18433, 18371, 18778<br />

END<br />

A sample run produces output such as:<br />

What year are you interested in? 1987<br />

In 1987 Springfield had the largest population.

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

Saved successfully!

Ooh no, something went wrong!