Texas Instruments TI-89 用户手册
![Texas Instruments](https://files.manualsbrain.com/attachments/b46f99d826b2b0e0e5f558c5fb6483942eb9216b/common/fit/150/50/c15ea36eb1fb1cce99a3b94668675bfc78ce832d8d727d9a7bb51a125510/brand_logo.gif)
Programming
637
Example: Using Alternative Approaches
Example: Using Alternative Approaches
Example: Using Alternative Approaches
Example: Using Alternative Approaches
The example in the Previews module 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.
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.
Example 1
Example 1
Example 1
Example 1
This example uses
InputStr
for input, a
While...EndWhile
loop to calculate the result, and
Text
to display the result.
Ê
Prompts for input on Program I/O screen.
Ë
Converts string entered with InputStr to an expression.
Ì
Loop calculation.
Í
Displays output in a dialog box.
Ê
Ë
Ì
©Ì
©Ì
©Ì
©Ì
Ì
Í
:prog1()
: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