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
$ g++ -std=c++17 QuadraticRootsCmdLine.cpp -o QuadraticRootsCmdLine -lfmt $ ./QuadraticRootsCmdLine 2 4 1 root #1: -0.292893 root #2: -1.70711 $ g++ -std=c++17 QuadraticRootsCmdLine.cpp -o QuadraticRootsCmdLine -lfmt $ ./QuadraticRootsCmdLine 1 -3.3 2.42 root #1: 2.2 root #2: 1.1

Solution