Home  |  IT Zone  |  Tips / Tricks  |  Did You Know  |  Inspirational  |  Health  |  World Infos  |  Insurance  |  Universities  |  Forex  |  Mathematics  |  Illusions  |  Children Day Quotes  |  Fun / Jokes  |  Decent Quotes  |  Birthday Msgs  |  Good Morning Msgs  |  Good Night Msg  |  Husband Wife Jokes  |  Teacher Students Jokes  |  Insult Jokes  |  Love Quotes  |  Sad Quotes  |  Funny Pics  |  Be Aware  |  Articles  |  Simple Joys of Life 

A program to find the roots of a quadratic equation

REM A program to find the roots of a quadratic equation ax2+bx+c=0, when the value of a, b and c are given. (QBasic Code)

CLS
INPUT "Enter the value of a"; a
INPUT "Enter the value of b"; b
INPUT "Enter the value of c"; c
k = (b ^ 2 - 4 * a * c)
IF k > 0 THEN
    x1 = (-b + k ^ (1 / 2)) / (2 * a)
    x2 = (-b - k ^ (1 / 2)) / (2 * a)
    PRINT "The first root is:"; x1
    PRINT "The second root is:"; x2
ELSE
    PRINT "The roots are imaginary."
END IF
END

Share :

Twitter
Back To Top

facebook main

Powered by Blogger.