Anda di halaman 1dari 2

BASIC COMPUTER LANGUAGE

Page 45

The Basic language was invented at Dartmouth College in the early 1960s. The
purpose was to provide a means for students of mathematics to solve algebraic
problems without having to first spend many hours learning how to do computer
programming. The end result has become a language so simple that a person can
write programs with little more than a minute or two of training!
A BIT OF HISTORY: The original
version of Basic, still available, is called
True Basic. It is available via
www.truebasic.com. It grew from an earlier
programming language called Fortran,
invented in the late 1950s. Prior to Fortran,
programming used binary numbers. Fortran
converted these to letter symbols and True
Basic further simplified the language.
In the late 1960s, versions were made
available on Mini Computers (which filled
up a rack of apparatus). Some software was
available via an ordinary telephone line, one
being from Hewlett Packard about 1970. An
old fashioned Teletypewriter was used for
input and output. In the 1970s, 8-bit
personal computers appeared, some with the
Basic language installed. A pioneer was the
Altair 8800. Then came the VIC 20 followed
by the popular Commodore 64. This was
followed by the Apple 8-bit and others.
In the early 1980s, Microsoft was formed
and the first version of their GW-BASIC was
offered for 16 bit computers using the disk
operating system. This language was perhaps
the easiest to use. It is no longer available
other than via the internet. Microsoft now
offers more elaborate and powerful versions..
Versions of Basic that compete with
Visual Basic include Liberty Basic, Just
Basic, True Basic, and others. GW-BASIC
differs from other versions of Basic in that
the language must be present in order to run
a program. This means that an application
program cannot be created for use on a
machine not equipped with GW-BASIC.
GW-BASIC may be available as a download
from the internet and it will function on the
current Windows operating system.
Most forms of Basic permit calling an
assembly language program in order to

maximize speed and simplicity. Most allow


communications with external objects such
as machinery, even by means of speech word
recognition. (Covox products supported
speech recording, playback, and word
recognition with early 8-bit computers and
with versions based on DOS and XP
operating systems.)
POWER LAW GROWTH: Recall the
article that calculates the growth of a dollar
over a period of many years. At 6% simple
interest, the value of one dollar at the end of
one year is $1.06. After two, three, and N
years it becomes 1.06^2, 1.06^3, and
1.06^N. With the calculator, enter the
starting amount 1. Multiply by 1.06 and
press equals to get 1.06. Multiply this
number by 1.06 to get 1.06*1.06=1.06^2.
Continue multiplying the number shown on
the display by 1.06 to get year-by year
growth. The calculations constitute a kind of
looping process.
Here is a very simple program in GWBASIC that achieves the result.
10 V=1
20 X=1.06
30 FOR K=1 TO 10
40 V=V*X
50 PRINT K,V
60 NEXT K
70 END
Looping is accomplished with the FORNEXT loop. For the first loop, K=1 and we
get V defined as the original value V=1
times X=1.06 to get V=1.06. This is shown
on the screen with the PRINT statement
which also shows the value of K. The second
time through the loop we get the redefined
value of V as V=1.06 times 1.06 to get
1*1.06*1.06= 1.1236, And so on. Each
printing shows how the dollar has grown

along with the value of K (years) that apply.


The process is much the same as what we did
using the calculator.
In GW-BASIC, we must number the
statements in ascending order. It is
customary but not necessary to number in
steps of 10. If we have forgotten a statement,
it can be inserted as a number between steps.
All letters are capitalized. If letters are
inserted in lower case, the program
automatically changes them to capitals. (To
print out lower case letters, they must be
enclosed in quotes in the print statement.)
If you make a typing error and want to
correct a statement, do so with an insertion.
But in order to properly install the result,
step to the end of the statement and then
press return.
We show statement 50 as PRINT K,V.
The two numbers are printed with a several
step gap between then. To close the gap, use
a semi-colon instead of a comma.
If you use BASIC programs other than
GW-BASIC you do not have to use line
numbers. Also, precede defined variables
with LET. For example, 40 V=V*X becomes
LET V=V*X.
You can generalize the GW-BASIC
program. Replace statements 10 and 20 with
10 INPUT V,I,N
20 X=1+I
When you run the program, you must
input three numbers, the starting value
(almost any number of dollars), the interest
rate I in decimal form (at 6% use 0.06), and
the upper limit on the looping variable K.
Statement, 20 finds X=1+I (1.06 for 6%).
You can use the same program to find
growth of money with interest calculated
monthly by using the decimal value of I/12.
Want to round off to the nearest dollar?
Use the INT statement. This ignores the
decimal place. That is, INT(3.2)=3 and
INT(3.9)=3. Add 0.5 to the variable. Then
INT(3.2+0.5)=INT(3.7)=3 and INT(3.9+0.5)
= INT(4.4)=4. You can round off to the
penny by multiplying the number by 100,
find INT, then divide the result by 100.
Was this so difficult to understand?

CALCULATING
PI:
With
the
information provided here, you should be
able to understand the computer program
described in a later discussion that finds the
value of Pi to one part out of 30 million.
(The version of Basic uses more digits in
calculations than the simple calculator.)
GRAPHS WITH BASIC: Suppose we
have a function such as y=100*x/(x^2+10)
and we want to plot a graph of this function
for x>zero. We will rotate the display by 90
degrees so that values of y are horizontal and
values for x along with marks for y values
are vertical and downward. We will use the
TAB function in GW-BASIC. A calculated
mark is moved to the right with the number
of steps equal to the value of the function.
This example does not include axes lines
or numbers other than values of x up to 5.
10 FOR X=0 TO 10
20 Y=100*X/(X^2+5)
30 PRINT TAB(X+10)*
40 NEXT X
50 END
An ordinary typewriter (or computer
keyboard) can create graphs. Again have the
y-axis horizontal and the x-axis vertical and
downward. Step the space bar to the right to
represent the computed number, starting at
perhaps 10 to represent zero. Type a zero of
other symbol to define the value. Could this
be helpful in teaching mathematics in
schools?
OTHER COMMANDS: We have only
scratched the surface in describing the things
that can be done with Basic. Some graphical
techniques also are available. All we want to
do here is to show how to calculate and print
certain algebraic functions.
The simple function above can be
expanded to represent complex functions
having many factors in the numerator and
many in the denominator. Exponents need
not be simple numbers. Furthermore, factors
can depend on y and z values to describe
functions above surfaces or space.
Page 46

Anda mungkin juga menyukai