title: Free Pascal, trouble with nested ifs and elses
body: <p>Can someone tell me what is wrong with my code? It is supposed to solve quadratic equations:</p>
  
  <pre><code>program quadraticeq;
  uses crt;
  var
      a,b,c,x1,x2,R1,I1,R2,I2,D: integer;
      p:1..4;
  begin
      writeln (output, 'Enter a,b i c:');   {ax^2 + bx + c = 0}
      readln (a,b,c);
  
      D:=sqr(b)-4*a*c;  {discriminant}
  
      if a=0 then
          p:=1
      else  
          if D=0 then begin
              p:=2;
              x1:=(-b)/(2*a);
              end
          else
              if D&gt;0 then begin
                  p:=3;
                  x1:=(-b+sqrt(D))/(2*a);
                  x2:=(-b-sqrt(D))/(2*a);
              end
              else begin
                  p:=4;
                  R1:=(-b)/(2*a);
                  I1:=sqrt(-D)/(2*a);
                  R2:=-R1;
                  I2:=-I1;
          end;
  
      case p of
      1:  writeln (output, 'Wrong entry! Quantificator a mustnt be zero!');
      2:  writeln (output, 'Double root of the equation is: x1=x2=',x1);
      3:  writeln (output, 'Roots of the equation are x1=',x1,'and x2=',x2,'.');
      4:  writeln (output, 'Complex roots of the equation are x1=',R1,'+i',I1,' and x2=',R2,'+i',I2,'.');
      end;
  end.
  </code></pre>