Pascal语法错误85

时间:2014-03-05 19:39:40

标签: pascal freepascal error-code turbo-pascal

首先,我是编程新手,我刚刚开始学习pascal。我遇到了错误85:";"预期。我多次搜索整个事情,但我还没有找到问题。有什么建议吗?

以下是代码:

program test;
var
  a,b,c:real;
begin
  D:=sqr(b)-4*a*c;
  writeln('Enter a value for a');
  readln(a);
  writeln('Enter a value for b');
  readln(b);
  writeln('Enter a value for c');
  readln(c);
  if ( D<0 ) then
  begin
    writeln('There is no solution.');
  else
  if ( D>0 ) then
  begin
    x1:=(-b+sqrt(D))/2*a;
    x2:=(-b-sqrt(D))/2*a;
    writeln('x1 is:');
    writeln('x1:=',x1);
    writeln(x2 is:);
    writeln('x2:=',x2);
  end;
end.

2 个答案:

答案 0 :(得分:3)

您有三个begin和两个end语句。缩进你的代码,你会发现你的错误。变量D,X1和X2也是未定义的。输出中还有其他语法错误,即在最近的'语句中缺少抽头标记writeln

答案 1 :(得分:0)

在其他地方之前你需要end ..

program test;
var
  a,b,c:real;
begin
  D:=sqr(b)-4*a*c;
  writeln('Enter a value for a');
  readln(a);
  writeln('Enter a value for b');
  readln(b);
  writeln('Enter a value for c');
  readln(c);
  if ( D<0 ) then
  begin
    writeln('There is no solution.');
  end 
  else
  if ( D>0 ) then
  begin
    x1:=(-b+sqrt(D))/2*a;
    x2:=(-b-sqrt(D))/2*a;
    writeln('x1 is:');
    writeln('x1:=',x1);
    writeln(x2 is:);
    writeln('x2:=',x2);
  end;
end.