Pascal if/else program syntax error

后端 未结 2 1502
旧巷少年郎
旧巷少年郎 2020-12-21 15:37

I have created a program to determine if a quadratic equation gives a \'real\' number as its answer and if so, what it is. However, this is my first time working with if/els

2条回答
  •  情书的邮戳
    2020-12-21 15:54

    You can't use semicolons in your last statement before your else statement.

    program Quadratic_Equation_Solver;
    
    {$mode objfpc}{$H+}
    
    uses
    Classes, SysUtils, CustApp;
    var
    a, b, c : real;
    begin
     writeln('Insert the Value for a please');
     readln(a);
     writeln('Insert the Value for b please');
     readln(b);
     writeln('Insert the Value for c please');
     readln(c);
       if (-4*a*c>b*b) then
        begin
        writeln('These variables return an imaginary quantity that');
        writeln('Cannot be computed. Please try again')
       end (*When using an else statement dont use semicolons*)    
     else 
    Writeln('The Answer is x = ',(-b+sqrt((b*b)-(4*a*c))/(2*a)):8:2);
    readln;
    end.
    

提交回复
热议问题