roots of quadratic equation-programmingraja

Aim: Write a program in prolog to give information about roots of quadratic equation.

Software Used: SWI- PROLOG

coding:

solve(A*_^2+B*_+C=0,L) :- D is B^2-4*A*C,

   (D < 0 -> L = [];

    D =:= 0 -> X is (-B)/(2*A), L = [X];

    S is sqrt(D), X1 is (-B-S)/(2*A),

      X2 is (-B+S)/(2*A), L=[X1,X2]).


OUTPUT :




Post a Comment

0 Comments