Syntax error in pascalABC

School problem for finding the number of roots of a square equation. When compiling, it returns a syntax error "main.pas(20,9) Fatal: Syntax error,"; " expected but "identifier WRITELN" found"

program discriminant;
var a, b, c, disc: integer;
begin
writeln('Эта программа находит колличество корней квадратного уравнения');
writeln('ax^2+bx+c=0');

write('A = ');
readln(a);

write('B = ');
readln(b);

write('C = ');
readln(c);

disc := (b*b)-(4*a*c);

if (disc > 0) then
    writeln('D = ', disc)
    writeln('Два корня')
else if (disc = 0) then
    writeln('D = ', disc)
    writeln('Один корень')
else if (disc < 0) then
    writeln('D = ', disc)
    writeln('Корней нет')
end.

I tried to put dots with commas in different variations. It didn't help. What should I do?

Author: lifono656, 2020-12-14

2 answers

A working version of the program. But this is a terry Turbo Pascal.

program discriminant;

var
  a, b, c, disc: integer;

begin
  writeln('Эта программа находит количество корней квадратного уравнения');
  writeln('ax^2+bx+c=0');
  write('A = ');
  readln(a);
  write('B = ');
  readln(b);
  write('C = ');
  readln(c);
  disc := (b * b) - (4 * a * c);
  if (disc > 0) then begin
    writeln('D = ', disc);
    writeln('Два корня')
  end    
  else if (disc = 0) then begin
    writeln('D = ', disc);
    writeln('Один корень')
  end    
  else if (disc < 0) then begin
    writeln('D = ', disc);
    writeln('Корней нет')
  end
end.

Below is the code PascalABC.NET:

begin
  Println('Эта программа находит количество корней квадратного уравнения');
  Println('Ax^2+Bx+C=0');
  var (a, b, c) := ReadReal3('введите через пробел A, B, C:');
  var disc := b * b - 4 * a * c;
  Println('D =', disc);
  case Sign(disc) of
  1: Print('Два разных корня');
  0: Print('Два равных корня');
  -1: Print('Действительных корней нет')
  end
end.

enter a description of the image here

 1
Author: RAlex, 2020-12-14 20:47:40

A semicolon is placed between statements (statements), but not after the last one. Accordingly, a semicolon is not placed before else and end.

In addition, you can not shove several operators in if and else - you must additionally wrap them in begin t end.

if условие then begin
  оператор(1);
  оператор(2);
  оператор(3)
end else ...
 0
Author: Qwertiy, 2020-12-14 20:56:41