Programming
621
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.
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
Содержание Titanium TI-89
Страница 9: ...Getting Started 6 TI 89 Titanium keys Ë Ì Í Ê ...
Страница 34: ...Getting Started 31 2 or D 2 B u s i n e s s D B D B Press Result ...
Страница 43: ...Getting Started 40 3 0 D B D D B D Press Result ...
Страница 44: ...Getting Started 41 D 2 0 0 2 D B Scroll down to October and press Press Result ...
Страница 58: ...Getting Started 55 Example Set split screen mode to TOP BOTTOM Press Result 3 B D ...
Страница 70: ...Getting Started 67 ...
Страница 175: ...Operating the Calculator 172 From the Keyboard ...
Страница 456: ...Tables 453 ...
Страница 503: ...Split Screens 500 Note Both Top Bottom and Left Right splits use the same methods to select an application ...
Страница 527: ...Data Matrix Editor 524 ...
Страница 704: ...Connectivity 701 A TI 89 Titanium and a Voyage 200 linked together I O Port I O Port I O unit to unit cable ...