₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,330,573 members, 8,446,085 topics. Date: Thursday, 16 July 2026 at 05:36 AM

Toggle theme

Programming CHALLENGE (3) - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingProgramming CHALLENGE (3) (748 Views)

1 Reply (Go Down)

Programming CHALLENGE (3) by elvis10ten(op): 8:01pm On Jul 16, 2013
Write a program that will use the method of completing the square to solve a quadratic equation.
SAMPLE INPUT:
2x² + 5x - 3 = 0
SAMPLE OUTPUT:
x = 1/2 or x = - 3
HINTS
1)Only the addition and substraction operator are allowed in the input equation.
2)Only three co-efficients are used in the equation.
RULES
1)Your code must be robust and work with any input.
2)Run your code on www.ideone.com.
3)Fastest and shortest code wins.
4)It should be able to run on a poor cpu. Good luck
Re: Programming CHALLENGE (3) by ooman(m): 7:53am On Jul 17, 2013
x=(-b+math.sqrt(b**2-4*a*c))/(2*a)

or

x=(-b-math.sqrt(pow(b,2)-4*a*c))/(2*a)

all others are simple.

note the operator diff after each -b

Python. Same applies to Java.
Re: Programming CHALLENGE (3) by elvis10ten(op): 2:52pm On Jul 17, 2013
ooman: x=(-b+math.sqrt(b**2-4*a*c))/(2*a)

or

x=(-b-math.sqrt(pow(b,2)-4*a*c))/(2*a)

all others are simple.

note the operator diff after each -b

Python. Same applies to Java.
hello ?. Quadratic formula and completing the square are two different things. Though quadratic formula was derived from completing the square.
Re: Programming CHALLENGE (3) by ooman(m): 5:52pm On Jul 17, 2013
elvis10ten: hello ?. Quadratic formula and completing the square are two different things. Though quadratic formula was derived from completing the square.
so your point?
Re: Programming CHALLENGE (3) by elvis10ten(op): 7:25pm On Jul 17, 2013
ooman: so your point?
Please read the question before posting, it says using completing the square method.
1 Reply

Programming Challenge For Beginners Competition Two N20000 -SEASON 2-Programming Challenge For Beginners N20000Facebook Programming Challenge Question234

Programmers Which Do U Prefer Psuedo Code Or Flow Chart.How Good Are You At ProgrammingGet Paid To Talk About What You Love