Created
May 23, 2016 07:40
-
-
Save dejibimbolaAyo/b036df8af979e19c325faa74487e9e46 to your computer and use it in GitHub Desktop.
algorithm for quadratic equation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//prompt user to enter coefficients of the quadratic equation | |
Enter value for a | |
Enter value for b | |
Enter value for c | |
square_b= b*b | |
neg_b= b* (-1) | |
two_a= 2*a | |
neg_four_a_c= 4*a*c*(-1) | |
square_b_minus_4ac= square_b - neg_four_a_c | |
if (square_b_minus_4ac < 0) //if b2-4ac (the discriminant) is less than 0, then the quadratic eqn has no solution | |
output: quadratic equation has no solution | |
else | |
root_of_square_b_4ac= Root of square_b_minus_4ac | |
upper_calc_one= neg_b + root_of_square_b_4ac | |
upper_calc_two= neg_b - root_of_square_b_4ac | |
x_one= upper_calc_one / two_a | |
x_two= upper_calc_two / two_a | |
output: | |
x_one, x_two |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
//prompt user to enter coefficients of the quadratic equation
Enter value for a
Enter value for b
Enter value for c
square_b= b_b
neg_b= b_ (-1)
two_a= 2_a
four_a_c= 4_a*c
square_b_minus_4ac= square_b - four_a_c
if (square_b_minus_4ac < 0) //if b2-4ac (the discriminant) is less than 0, then the quadratic eqn has no solution
output: quadratic equation has no solution
else
root_of_square_b_4ac= Root of square_b_minus_4ac
upper_calc_one= neg_b + root_of_square_b_4ac
upper_calc_two= neg_b - root_of_square_b_4ac
x_one= upper_calc_one / two_a
x_two= upper_calc_two / two_a
output:
x_one, x_two