Roots of a quadratic function: Difference between revisions

Content added Content deleted
Line 848: Line 848:


=={{header|IS-BASIC}}==
=={{header|IS-BASIC}}==
<lang IS-BASIC>100 PROGRAM "Quadratic.bas"
<lang IS-BASIC>
100 PROGRAM "Quadratic.bas"
110 INPUT PROMPT "a= ,b= ,c= ":A,B,C
110 PRINT "Enter coefficients a, b and c:":INPUT PROMPT "a= ,b= ,c= ":A,B,C
120 LET D=B^2-4*A*C
120 IF A=0 THEN
130 SELECT CASE SGN(D)
130 PRINT "The coefficient of x^2 can not be 0."
140 CASE 0
140 ELSE
150 PRINT "The single root is ";-B/2/A
150 LET D=B^2-4*A*C
160 CASE 1
160 SELECT CASE SGN(D)
170 PRINT "The real roots are ";(-B+SQR(D))/(2*A);"and ";(-B-SQR(D))/(2*A)
180 CASE -1
170 CASE 0
190 PRINT "The complex roots are ";-B/2/A;"+/- ";STR$(SQR(-D)/2/A);"*i"
180 PRINT "The single root is ";-B/2/A
190 CASE 1
200 END SELECT</lang>
200 PRINT "The real roots are ";(-B+SQR(D))/(2*A);"and ";(-B-SQR(D))/(2*A)
210 CASE -1
220 PRINT "The complex roots are ";-B/2/A;"+/- ";STR$(SQR(-D)/2/A);"*i"
230 END SELECT
240 END IF</lang>


=={{header|J}}==
=={{header|J}}==