Pure Programmer
Blue Matrix


Cluster Map

Project: Quadratic Roots (Command Line)

Quadratic equations of the form Ax2 + Bx + C = 0 have two possible solutions given by the [[Quadratic Formula]]. Write a program that prints the two possible roots of a quadratic equation. Then values A, B and C should be passed in on the command line.

See: QuadraticRoots

Output
$ perl QuadraticRootsCmdLine.pl 2 4 1 root #1: -0.292893218813452 root #2: -1.70710678118655 $ perl QuadraticRootsCmdLine.pl 1 -3.3 2.42 root #1: 2.2 root #2: 1.1

Solution