answersLogoWhite

0


Best Answer

Exercise : Write a program to solve quadratic equations (ax^2 + bx + c), using a subroutinesub quadratic(a as double, b as double, c as double, indicator as long, root1 as double, root2 as double)

Input parameters are a, b, c.

Output parameters are :indicator (= 0 , two identical roots, = 1, two distinct real roots, = 2 , complex roots )

For real roots : they are stored in "root1" and "root2".

For complex roots : root1 = real part, root2 = imaginary part.

Ans : DEFLNG I-N DEFDBL A-H, O-Z L20: INPUT " Coefficients a,b,c (a*x^2+b*x+c) "; a, b, c CALL quadratic(a, b, c, iflag, r1, r2) IF iflag = 0 THEN PRINT "2 Identical roots "; r1 ELSEIF iflag = 1 THEN PRINT "2 distinct real roots "; r1; r2 ELSE PRINT "Complex root" PRINT "real part "; r1; "imaginary part "; r2 END IF GOTO L20 END SUB quadratic (a AS DOUBLE, b AS DOUBLE, c AS DOUBLE, indicator AS LONG, root1 AS DOUBLE, root2 AS DOUBLE) rem rem Input parameters: rem a*x*x + b*x + c rem rem Output parameters: rem indicator = 0 two identical roots, = 1 two distinct real roots, = 2 , complex roots. rem root1, root2 stores the real and imaginary part when complex roots occur. rem discrim = b * b - 4. * a * c IF discrim > 0 THEN dummy = SQR(discrim) indicator = 1 root1 = (-b + dummy) / (2. * a) root2 = (-b - dummy) / (2. * a) ELSEIF discrim = 0 THEN indicator = 0 root1 = -b / (2. * a) root2 = root1 ELSE indicator = 2 dummy = SQR(-discrim) root1 = -b / (2. * a) root2 = dummy / (2. * a) END IF END SUB

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do l write complete qbasic program to compute quadratic equation whose sides are A B C and print out your result?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Algebra

What is the meaning of fabs in quadratic equation in c program?

In the C Programming Language, the fabs function returns the absolute value of a floating-point number


The sum of two decimal numbers is 3.9 their difference is 0.9 and their product is 3.6 what are the two numbers?

If you use the quadratic equation, all you need to know are the first and last statement. The middle one can get confusing because you need to include absolute value. Set up a system of equations: {x+y=3.9 {x*Y=3.6 Solve the second one for x and you get x=3.6/y Substitute that for the x in the first equation and you get: (3.6/y) + y = 3.9 If you multiple the y by (y/y) you can change it to (y^2 / y) So the equation becomes: (3.6/y) + (y^2/y) = 3.9 Add like terms to get: (3.6 + y^2)/y = 3.9 Multiple both sides by y to get: 3.6 + y^2 = 3.9y Get all the terms one side and re-order them to make it look like a quadratic equation: y^2 -3.9y + 3.6 = 0 Now use a calculator program or the quadratic formula to solve. You get that the numbers are 2.4 and 1.5


What is a powerful spreadsheet program that allow users to organize data complete calculations make decisions graph data develop professional looking reports publish organized data on the web?

Access Work Area


What is difference between interpreters and compiler?

Interpreter An interpreter is given a computer program to run and it is executed (or performed) line by line. It simply reads a line of code (in the programs native language (ie English Basic) and performs the instructions one by one. After each line has been completed, the next on is accessed and duly performed until the program is finished. The syntax of the program may have errors in it and these are not found out until the program is run. The user must have the source code to be able to run the program (some interpreters produces a tokenised version of the source code to speed up execution of the program and reduce disk storage.) Compiler. With a compiler, the entire code is translated into machine code before it is run and then saved to disk for future use. The entire program must be 100% syntax correct before the program is translated and saved to disk. Several other parts of the program (called libraries) can be linked with the program to produce the final product. Test compilations usually are performed to avoid a large number of compile errors at once. The compiled program is accessed by the user but they do not need the source code to use the program. The same program run as a compiled program will usually outperform an interpreted on.


Difference between top down program design and bottom up program design?

Top down Program Design : Begins the design with main or top-level module, and progresses downwards to the lowest level modules or subsystem Bottom down Program Design : Begins the design with the lowest level modules or subsystems, and progresses upward to the main program, module or subsystem.

Related questions

A program using bufferedreader in quadratic equation?

doctor


Algorithm to find the roots of a quadratic equation?

The easiest way to write a generic algorithm is to simply use the quadratic formula. If it is a computer program, ask the user for the coefficients a, b, and c of the generic equation ax2 + bx + c = 0, then just replace them in the quadratic formula.


Where can someone find information on quadratic equation solvers?

If you are looking to download an app on your ti-84 or higher calculator, you should watch the "Quadratic Formula Program on the Ti-84" on youtube. Best of Luck!


Write the full program for the quadratic equation in COBOL?

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.


What is the meaning of fabs in quadratic equation in c program?

In the C Programming Language, the fabs function returns the absolute value of a floating-point number


Write a program in C programming language that computes the roots of the quadratic equation ax2 plus bx plus c?

Write your program and if you are having a problem post it here with a description of the problem you are having. What you are asking is for someone to do your homework for you.


What is the verb for computer?

The verb for computer is compute.Other verbs are computes, computing and computed."I am computing"."We have computed the program""I like to compute".


How do engineers use the quandratic formula?

Law of motion is quadratic equation and is use in calculate of object trajectory. Fluid dynamic for sizing of pump is also second order equation. Quadratic equation or higher may use to fit equation for fast calculation of result. Example on vapour density equation for the use of evaporative mass transfer. We do need to know how much water air can take. It could use the data from table but the work will be lengthly. We can make data in the table a form of polynomial equation and so put it into program for calculated out this require vapour density.


How do you write a program to solve a quadratic equation which has upto power 2 for example xto power 2 plus product of and x subtract 3 equals to 0?

to solve ax2 + bx + c use the quadratic formula: (-b +/-(b2 - 4ac))/2a. Programming this should be a doddle.


How do you program the quadratic formula into your calculator?

It all depends on what calculator you use to know how to program the formula into it.


Write a pascal program that compute an area of a triangle?

{A program to compute the area of a triangle} {by Ogboin W. Meshach} Var; b,h:real; BEGIN Writeln('Triangle'); Write('Base: '); Readln(base); Write('Height: '); Readln(height); area:=0.5*base*height; Writeln('Area: ', area :0:2); End.


Write a program to find the square root of the quadratic equation using flow chart?

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.