What is the problem with this program?

noha -  
brucine Posted messages 24674 Registration date   Status Member Last intervention   -
Hello, here is the program but they tell me compilation failure + I tried this morning and the execution window stops

Program equation;
Var
a,b,c,s1,s2,s3,delta: Real;
Begin
Writeln('enter the respective values of a, b, and c');
Readln(a,b,c);
If a=0 Then
Writeln('this equation is of the first degree')
Else
Begin
Writeln('this equation is of the second degree');
delta := (b*b)-(4*a*c)
End;
If delta>0 Then
Begin
s1 := (-b+Sqrt(delta))/(2*a);
s2 := (-b-Sqrt(delta))/(2*a);
Writeln('The solutions of this equation are:',s1:2:2,'and',s2:2:2)
End
Else If delta=0 Then
Begin
s3 := (-b)/(2*a);
Writeln('The solution of this equation is:',s3:2:2)
End
Else
Writeln('the solution is an empty set');
Readln;
End.

Configuration: Windows / Chrome 100.0.4896.88

1 answer

ccm81 Posted messages 11033 Status Member 2 434
 
Hello

Program equation; Var a,b,c,s1,s2,s3,delta: Real; Begin Writeln('enter the respective values of a, b and c'); Readln(a,b,c); If a=0 Then Writeln('this equation is of the first degree') Else Begin Writeln('this equation is of the second degree'); delta := (b*b)-(4*a*c); If delta>0 Then Begin s1 := (-b+Sqrt(delta))/(2*a); s2 := (-b-Sqrt(delta))/(2*a); Writeln('The solutions of this equation are:',s1:2:2,'and',s2:2:2) End Else If delta=0 Then Begin s3 := (-b)/(2*a); Writeln('The solution of this equation is:',s3:2:2) End Else Writeln('the solution is an empty set'); End; Readln; End. 


Cheers
0
brucine Posted messages 24674 Registration date   Status Member Last intervention   4 142
 
Hello,

This leaves us hungry for more: what about the solutions when the equation is of the first degree, when in this case b is zero and not c, when a, b, and c are all zero, when the discriminant is negative (which doesn't innovate otherwise of course it is appropriate to calculate the square root of -delta and that the solutions are complex)?
0