Division by 0
Résolu
mano2003
Messages postés
50
Date d'inscription
Statut
Membre
Dernière intervention
-
bizu53 Messages postés 1274 Date d'inscription Statut Membre Dernière intervention -
bizu53 Messages postés 1274 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
j'ai un problème pour compiler un programme en turbo pascal qu'on nous a donné en exo qui consiste à résoudre l'équation axx+bx+c=0 mais il m'écrit que y'a erreur division by zero pour les cas c=0 et bx+c=0. aidez moi svp voici mon algo:
program equation_2nd_degre;
uses crt;
var a,b,c,x,x0,x1,x2,delta:real;
begin
write('Donnez a: '); read(a);
write('Donnez b: '); read(b);
write('Donnez c: '); read(c);
delta:=(b*b)-(4*a*c);
if (a=0) and (b=0) and (c<>0) then
writeln('Cette ‚quation n''existe nulle part!!!')
else
if (a=0) and (b<>0) and (c<>0) then
begin
write('L''‚quation est du 1er degr‚ et admet une solution x0: ',x0);
x0:=(-c/b);
writeln(x0);
end;
if (a=0) and (b=0) and (c=0) then
writeln('Il n''y a pas de solution!!!')
else
if (a<>0) and (b<>0) and (c<>0) or (c=0) then
writeln('L''‚quation est du 2nd degr‚');
if delta>0 then
begin
writeln('L''‚quation admet 2 solutions distinctes x1 et x2: ');
x1:=(-b-sqrt(delta))/(2*a);
x2:=(-b+sqrt(delta))/(2*a);
writeln('x1=',x1);
writeln('x2=',x2);
readln;
end
else
if delta=0 then
begin
writeln('L''‚quation admet une racine double x0: ');
x0:=-b/(2*a);
writeln('x0=',x0);
readln;
end
else
if delta<0 then
begin
writeln('L''‚quation n''admet pas de solution dans IR !!!');
readln;
end;
readln;
clrscr;
end.
j'ai un problème pour compiler un programme en turbo pascal qu'on nous a donné en exo qui consiste à résoudre l'équation axx+bx+c=0 mais il m'écrit que y'a erreur division by zero pour les cas c=0 et bx+c=0. aidez moi svp voici mon algo:
program equation_2nd_degre;
uses crt;
var a,b,c,x,x0,x1,x2,delta:real;
begin
write('Donnez a: '); read(a);
write('Donnez b: '); read(b);
write('Donnez c: '); read(c);
delta:=(b*b)-(4*a*c);
if (a=0) and (b=0) and (c<>0) then
writeln('Cette ‚quation n''existe nulle part!!!')
else
if (a=0) and (b<>0) and (c<>0) then
begin
write('L''‚quation est du 1er degr‚ et admet une solution x0: ',x0);
x0:=(-c/b);
writeln(x0);
end;
if (a=0) and (b=0) and (c=0) then
writeln('Il n''y a pas de solution!!!')
else
if (a<>0) and (b<>0) and (c<>0) or (c=0) then
writeln('L''‚quation est du 2nd degr‚');
if delta>0 then
begin
writeln('L''‚quation admet 2 solutions distinctes x1 et x2: ');
x1:=(-b-sqrt(delta))/(2*a);
x2:=(-b+sqrt(delta))/(2*a);
writeln('x1=',x1);
writeln('x2=',x2);
readln;
end
else
if delta=0 then
begin
writeln('L''‚quation admet une racine double x0: ');
x0:=-b/(2*a);
writeln('x0=',x0);
readln;
end
else
if delta<0 then
begin
writeln('L''‚quation n''admet pas de solution dans IR !!!');
readln;
end;
readln;
clrscr;
end.