Identification division.
Program-id. Quadratic.
Environment division.
Data division.
Working-storage section.
01 a pic 9(3) value 0.
01 b pic 9(3) value 0.
01 c pic 9(3) value 0.
01 d pic 9(3) value 0.
01 e pic 9(3) value 0.
01 f pic 9(3) value 0.
01 g pic 9(3) value 0.
01 h pic 9(3) value 0.
01 x1 pic 9(3) value 0.
01 x pic z(3).z(2) value 0.
01 x2 pic 9(3) value 0.
01 y pic z(3).z(2) value 0.
Procedure division.
Display "Written by Martin O. Egua, but not complete".
Display "Quadratic equation solver for three values a, b & c"
Display "Enter a number: " Accept a.
Display "Enter the second number: " Accept b.
Display "Enter the last number: " Accept c.
compute d = (b * b)
compute e = 4 * a * c
compute f = 2 * a
compute g = d - e
compute h = function sqrt (g).
compute x1 = (-b) + h
compute x = x1 / f
Display "X = " x
compute x2 = (-b) - h
compute y = x2 / f
Display "Y = " y
Display "Send the accurate program".
Stop run.
Chat with our AI personalities
You don't need a flow chart for that; just use the quadratic formula directly; most programming languages have a square root function or method. You would only need to do this in many small steps if you use Assembly programming. The formulae would be something like this: x1 = (-b + sqrt(b^2 - 4*a*c)) / (2 * a) and x2 = (-b - sqrt(b^2 - 4*a*c)) / (2 * a) where a, b, and c are the coefficients of the quadratic equation in standard form, and x1 and x2 are the solutions you want.
(Uses Square Root Function) PRINT "Ax^2 + Bx + C = 0" INPUT "A = ", A INPUT "B = ", B INPUT "C = ", C D = B * B - 4 * A * C IF D > 0 THEN DS = SQR(D) PRINT "REAL ROOTS:", (-B - D) / (2 * A), (-B + D) / (2 * A) ELSE IF D = 0 THEN PRINT "DUPLICATE ROOT:", (-B) / (2 * A) ELSE DS = SQR(-D) PRINT "COMPLEX CONJUGATE ROOTS:", (-B / (2 * A)); "+/-"; DS / (2 * A); "i" END IF END IF
The word evaluate in the programming language COBOL can be used to replace a nested if statement. Instead of long statement evaluate allows one to shorten the coding required and write cleaner code.
1-6 sequence numbers. 7 (*) for comment (-) for continue (D) for debugging. 8-11 called as Area-A in this Area we can write Divisions,Paragraphs,sections,Level numbers. 12-72 called as Area-B in this area we can write cobol executable statements like select,accept,display. 73-80 is ignored area by compiler but we can see in source Listing.
A c program is also known as a computer program. A singular matrix has no inverse. An equation to determine this would be a/c=f. <<>> The determinant of a singular matix is zero.