title: Compute real roots of a quadratic equation in Pascal
body: <p>I am trying to solve this problem :</p>
  
  <p>(Write a program to compute the real roots of a quadratic equation (ax<sup>2</sup> + bx + c = 0). The roots can be calculated using the following formulae:</p>
  
  <p>x1 = (-b + sqrt(b<sup>2</sup> - 4ac))/2a</p>
  
  <p>and</p>
  
  <p>x2 = (-b - sqrt(b<sup>2</sup> - 4ac))/2a</p>
  
  <p>I wrote the following code, but its not correct:</p>
  
  <pre><code>program week7_lab2_a1;
  var a,b,c,i:integer;
  x,x1,x2:real;
  
  begin
    write('Enter the value of a :');
    readln(a);
  
    write('Enter the value of b :');
    readln(b);
  
    write('Enter the value of c :');
    readln(c);
  
    if (sqr(b)-4*a*c)&gt;=0 then
      begin
        if ((a&gt;0) and (b&gt;0)) then
          begin
            x1:=(-1*b+sqrt(sqr(b)-4*a*c))/2*a;
            x2:=(-1*b-sqrt(sqr(b)-4*a*c))/2*a;
  
            writeln('x1=',x1:0:2);
            writeln('x2=',x2:0:2);
          end
        else
          if ((a=0) and (b=0)) then
            write('The is no solution')
          else
            if ((a=0) and (b&lt;&gt;0)) then
              begin
                x:=-1*c/b;
                write('The only root :',x:0:2);
              end;
      end
    else
      if (sqr(b)-4*a*c)&lt;0 then
        write('The is no real root');
  
    readln;
  end.
  </code></pre>
  
  <p>do you know why?</p>
  
  <p>and taking a=-6,b=7,c=8 .. can you desk-check it after writing the pesudocode?</p>