Solve a quadratic equation
Solve a quadratic equation
API Declarations
Dim x2 As Double
where x1 and x2 are the possible values
Rate Solve a quadratic equation
(1(1 Vote))
Dim x1 As Double
Dim x2 As Double
a = InputBox(" Enter the coefficient of x^2:a")
b = InputBox("Enter the coefficient of x:b")
c = InputBox("Enter the contant of the equation:c")
d = ((b * b) - (4 * a * c))
e = 2 * a
If Val(d) < 0 Then
MsgBox "the equation has no real or equal roots"
End If
If Val(d) >= 0 Then
f = Val(d ^ 0.5)
x1 = (-b + f) / e
x2 = (-b - f) / e
MsgBox " the roots of the equation are:" & Str(x1) & "," & Str(x2)
End If
End Sub
Solve a quadratic equation Comments
No comments yet — be the first to post one!
Post a Comment