为什么说我编写的if/else语句存在语法错误? [英] Why is it saying that there is a syntax error for the if/else statement I wrote?

查看:529
本文介绍了为什么说我编写的if/else语句存在语法错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个在TI-84上计算几何级数之和的程序.

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.

推荐答案

Else只能与If .. Then构造配对,不能与普通的If配对.所以:

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

通常,If.. Then .. Else .. End构造应由End关闭,但是在这种情况下,程序仍然退出,因此没有区别. TI-BASIC官方手册中对此有一些文档,您可以在此处中查看更详细的版本. >.

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.

这篇关于为什么说我编写的if/else语句存在语法错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆