Why is it saying that there is a syntax error for the if/else statement I wrote?

和自甴很熟 提交于 2019-12-02 15:56:15

问题


I'm trying to write a program that calculates the sum of a geometric series on a TI-84.

Prompt A

Prompt R

Prompt N

If N=100 and abs(R)<1

Disp (A/1-R)

Else

Disp (A(1-R^N))/(1-r)

It says that there is a syntax error at the Else line.


回答1:


Else can only be paired with an If .. Then construct, not a plain If. So:

Prompt A,R,N
If N=100 and abs(R)<1
Then
Disp A/(1-R
Else
Disp (A(1-R^N))/(1-R

In general the If.. Then .. Else .. End construct should be closed by End but in this case the program exits anyway so it makes no difference. There is some documentation of this in the official TI-BASIC manual and you can check out a more detailed version here.



来源:https://stackoverflow.com/questions/55768920/why-is-it-saying-that-there-is-a-syntax-error-for-the-if-else-statement-i-wrote

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!