09 December, 2013

A Program To Solve Quadratic Equation

Private Sub Command1_Click()
Dim a As Double
Dim b As Double
Dim c As Double
Dim d As Double
Dim e As Double
Dim f As Double
Dim g As Double
Dim h As Double
Dim i As Double
Dim j As Double
a = InputBox("a""input a")
b = InputBox("b""Input b")
c = InputBox("c""input c")
d = (b ^ 2) - 4 * a * c

e = 2 * a
f = d ^ (1 / 2)
g = -b + f
h = -b - f
i = g / e
j = h / e
Print "X1=" & i
Print "X2=" & j
End Sub

This one is more complex than the others because there is a lot of mathematics behind this program. You have to solve the quadratic equation from top to bottom using the normal maths after which you will convert the relevant steps of the maths into V.B code. Logical reasoning is also needed here.
I hope you understand this one.
Any question? Use the comment box.

No comments:

Post a Comment