Example: Using Alternative Approaches - Texas Instruments TI-89 Manual Book

Ti ti-89: user guide
Hide thumbs Also See for TI-89:
Table of Contents

Advertisement

Example: Using Alternative Approaches

Example 1
Example 2
Tip: For , type ¥ µ (zero).
For &, press:
.
89: ¥ p (times
TI
)
.
92 Plus: 2 H
TI
Example 3
Note: Because Prompt
returns n as a number, you
do not need to use expr to
convert n.
The preview at the beginning of this chapter shows a program
that prompts the user to enter an integer, sums all integers
from 1 to the entered integer, and displays the result. This
section gives several approaches that you can use to achieve
the same goal.
This example is the program given in the preview at the beginning of
the chapter. Refer to the preview for detailed information.
Prompts for input
in a dialog box.
Converts string entered
with Request to an
expression.
Loop calculation.
Displays output on
Program I/O screen.
This example uses
InputStr
calculate the result, and
Prompts for input on
Program I/O screen.
Converts string entered
with InputStr to an
expression.
Loop calculation.
Displays output
in a dialog box.
This example uses
Prompt
and
to display the result.
Disp
Prompts for input on
Program I/O screen.
Loop calculation.
Displays output on
Program I/O screen.
:prog1()
:Prgm
:Request "Enter an integer",n
:expr(n)! n
:0! temp
:For i,1,n,1
: temp+i! temp
:EndFor
:Disp temp
:EndPrgm
for input, a
While...EndWhile
to display the result.
Text
:prog2()
:Prgm
:InputStr "Enter an integer",n
:expr(n)! n
:0! temp:1! i
:While in
: temp+i! temp
: i+1! i
:EndWhile
:Text "The answer is "&string(temp)
:EndPrgm
for input,
and
Lbl
Goto
:prog3()
:Prgm
:Prompt n
:0! temp:1! i
:Lbl top
: temp+i! temp
: i+1! i
: If in
:
Goto top
:Disp temp
:EndPrgm
Chapter 17: Programming
loop to
to create a loop,
311

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ti-92 plusTi-92 plus

Table of Contents