0% found this document useful (0 votes)
551 views2 pages

Ecuatia de Gradul II - PLSQL

This document contains code to solve quadratic equations. It accepts coefficients for x^2, x, and x^0 as input. It then calculates the discriminant and outputs the two roots, checking for various cases like: a linear equation where it outputs the single root, a repeated root if the discriminant is 0, real/complex roots depending on the sign of the discriminant, and cases where coefficients are 0.

Uploaded by

simrey
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
551 views2 pages

Ecuatia de Gradul II - PLSQL

This document contains code to solve quadratic equations. It accepts coefficients for x^2, x, and x^0 as input. It then calculates the discriminant and outputs the two roots, checking for various cases like: a linear equation where it outputs the single root, a repeated root if the discriminant is 0, real/complex roots depending on the sign of the discriminant, and cases where coefficients are 0.

Uploaded by

simrey
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

SET SERVEROUTPUT ON -- cerinta date pentru accept v_coeficient_x2 accept v_coeficient_x1 accept v_coeficient_x0 coeficientii ecuatiei prompt 'Introduceti

coeficientul lui x2 (diferit de 0): ' prompt 'Introduceti coeficientul lui x1: ' prompt 'Introduceti coeficientul lui x0: '

-- declarare variabile declare v_coeficient_x2 number(5):=&v_coeficient_x2; v_coeficient_x1 number(5):=&v_coeficient_x1; v_coeficient_x0 number(5):=&v_coeficient_x0; v_delta number(5); v_x1 number(5); v_x2 number(5); begin if v_coeficient_x2=0 then dbms_output.put_line('Ecuatia este de gradul I si are solutia: '||-v_coeficient_ x0/v_coeficient_x1); end if; if v_coeficient_x1=0 then if (-v_coeficient_x0/v_coeficient_x2)>0 then v_x1:=-v_coeficient_x0/v_coeficient_x2; v_x2:=v_coeficient_x0/v_coeficient_x2; dbms_output.put_line('Prima radacina este: '||v_x1); dbms_output.put_line('A doua radacina este: '||v_x2); else if (-v_coeficient_x0/v_coeficient_x2)<0 then dbms_output.put_line('Ecuatia nu are solutii reale, acestea sunt complexe'); dbms_output.put_line('Prima radacina este: '||sqrt(v_coeficient_x0/v_coeficient_ x2)||' * i'); dbms_output.put_line('A doua radacina este: '||-sqrt(v_coeficient_x0/v_coeficien t_x2)||' * i'); end if; end if; end if; if v_coeficient_x2!=0 then v_delta:=((v_coeficient_x1*v_coeficient_x1)-(4*v_coeficient_x2*v_coeficient_x0)) ; if v_delta=0 then v_x1:=(-v_coeficient_x1/(2*v_coeficient_x2)); v_x2:=(-v_coeficient_x1/(2*v_coeficient_x2)); dbms_output.put_line('Discriminantul ecuatiei este: '||v_delta); dbms_output.put_line('Prima radacina este: '||v_x1); dbms_output.put_line('A doua radacina este: '||v_x2); else if v_delta>0 then v_x1:=(-v_coeficient_x1+sqrt(v_delta)/(2*v_coeficient_x2)); v_x2:=(-v_coeficient_x1-sqrt(v_delta)/(2*v_coeficient_x2)); dbms_output.put_line('Discriminantul ecuatiei este: '||v_delta); dbms_output.put_line('Prima radacina este: '||v_x1); dbms_output.put_line('A doua radacina este: '||v_x2); else if v_delta<0 and v_coeficient_x1!=0 then dbms_output.put_line('Ecuatia nu are solutii reale, acestea sunt complexe'); dbms_output.put_line('Discriminantul ecuatiei este: '||v_delta); dbms_output.put_line('Prima radacina este: '||-v_coeficient_x1/(2*v_coeficient_x 2)||' * '||sqrt(-v_delta)||' * i'); dbms_output.put_line('A doua radacina este: '||-v_coeficient_x1/(2*v_coeficient_ x2)||' * '||-sqrt(-v_delta)||' * i'); end if; end if;

end if; end if; end; /

You might also like