Westonci.ca is the Q&A platform that connects you with experts who provide accurate and detailed answers. Connect with a community of professionals ready to help you find accurate solutions to your questions quickly and efficiently. Experience the convenience of finding accurate answers to your questions from knowledgeable experts on our platform.

write a program in pascal to solve a quadratic equation

Sagot :

program p1;
var a,b,c,d : integer; {i presume you give integer numbers for the values of a, b, c }
     x1, x2 : real;
begin 
write('a='); readln(a);
write('b='); readln(b);
write('c=');readln(c);
d:=b*b - 4*a*c
if a=0 then x1=x2= - c/b
          else
if d>0 then begin 
                 x1:=(-b+sqrt(d)) / (2*a);
                 x2:=(-b - sqrt(d))/(2*a);
                end;
          else if d=0 then x1=x2= - b /(2*a)
                           else write ("no specific solution because d<0");
writeln('x1=', x1);
writeln('x2=',x2);
readln;
end.
We appreciate your time on our site. Don't hesitate to return whenever you have more questions or need further clarification. Thank you for visiting. Our goal is to provide the most accurate answers for all your informational needs. Come back soon. We're glad you chose Westonci.ca. Revisit us for updated answers from our knowledgeable team.