EasyManuals Logo
Home>Texas Instruments>Desktop>TI-99/4A

Texas Instruments TI-99/4A User Reference Guide

Texas Instruments TI-99/4A
204 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #73 background imageLoading...
Page #73 background image
FOR-
TO-STEP
FOR
control-variable =initial-value
TO
limit
[STEP
incrementl
The
FOR·TO·STEP
statement
is
used
for
easy programming
of
repetitive (iterative) processes. Together with the
NEXT
statement, the
FOR-TO'STEP
statement
is used to
construct
a
FOR-NEXT
loop_
If
the
STEP
clause is
umiued,
lhe
computer
uses an increment of +1.
The
control-varia.ble
is
a numeric variable which acts as a counter
for
the loop. When the
FORTO-STEP
statement
is
performed, the
control'variable is
set
to the initial-value.
The
computer then
performs
program
statements
until
it
F.ncounters a
NEXT
statement.
When the
NEXT
statement
is
performed, the computer increments
the
control-variable
by
the
amount
specified in the
STEP
clause.
(When the increment
is
a negative value, the control'variable is
actually reduced by the
STEP
amount.)
The
computer then
compares the
control-variable to the value of the limit. If the
control·variable does not yet exceed the limit, the computer repeats
the
statements
following the
FOR·TO-STEP
statement
until the
NEXT
statement
is
again encountered
and
performed_
If
the new
value for the
control-varia.ble
is
greater
than
the limit (if the
increment is positive)
or
less than the limit (if the increment
is
negative). the computer leaves the loop and continues with the
program
statement
following the
NEXT
statement.
The
value of
the
control-variable
is
not changed when the computer leaves the
FORNEXT
loop.
You control the number of times the
FOR-NEXT
loop
is
performed
by
the values you assign in the
FOR-TO'STEP
statement.
The
limit, and, optionally, the
STEP
increment
are
numeric·expressions
that
are
evaluated once during a loop performance (when the FOR-
TO-~TEP
statement
IS
encountered)
and
remain in effect until the
loop is finished. Any change
made
to these values while a loop is in
progress has
no
effect on the number of times the loop is performed.
If
the
value of the lflcrement IS zero, the computer displays the error
message "BAD VALUE
IN
xx"
and
the program stops running.
User's Reference Guide
Examples:
>NEIoI
>100
REM
COMPUTING
SIMPLE
INTEREST
FOR
10
YEARS
>110
INPUT
"PRINCIPLE?
":P
>120
INPUT
"RATE?
":R
>130
FOR
YEARS:1
TO
10
>140
P:P+(P*R)
>150
NEXT
YEARS
>160
P:INT(P*100+.5)/100
>170 PRINT P
>180
END
>RUN
PRINCIPLE?
100
RATE?
.0775
210.95
**
DONE
**
>NEW
>100
REM
EXAMPLE
OF
FRACTIONAL
INCREMENT
>110
FOR
X=.1
TO
1
STEP
.2
>120 PRINT
X;
>130
NEH
X
>140 PRINT
:X
>150
END
>RUN
.1
.3
.5
.7
.9
1.1
""
DONE
>NEW
>100
L=5
>110
FOR
1:1
TO
L
>120
L:ZO
>130 PRINT
L;I
>140
NEH
I
>150
END
>RUN
20
1
20
2
20
3
20
4
20 5
**
DONE
**
ll-53

Other manuals for Texas Instruments TI-99/4A

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments TI-99/4A and is the answer not in the manual?

Texas Instruments TI-99/4A Specifications

General IconGeneral
BrandTexas Instruments
ModelTI-99/4A
CategoryDesktop
LanguageEnglish

Related product manuals