Roots of a quadratic function: Difference between revisions

m
Line 848:
 
=={{header|IS-BASIC}}==
<lang IS-BASIC>100 PROGRAM "Quadratic.bas"
100 PROGRAM "Quadratic.bas"
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 CASEELSE 0
150 PRINT "The single root is ";-B/2/A
120150 LET D=B^2-4*A*C
160 CASE 1
130160 SELECT CASE SGN(D)
170 PRINT "The real roots are ";(-B+SQR(D))/(2*A);"and ";(-B-SQR(D))/(2*A)
180170 CASE -10
190180 PRINT "The complexsingle rootsroot areis ";-B/2/A;"+/- ";STR$(SQR(-D)/2/A);"*i"
160190 CASE 1
200 END SELECT</lang>
170200 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
200240 END SELECTIF</lang>
 
=={{header|J}}==
Anonymous user