The Quadratic Formula solves the quadratic equation for x. This training project, prepared by Codecademy.
In algebra, a quadratic equation is an equation having the form:
ax2 + bx + c = 0
Graphing, we get the curve below:
The corresponding x values are the x-intercepts of the graph, while a, b, and c are constants.
Write a C++ program called quadratic.cpp
that solves the quadratic equation for the x‘s:
- C++
How to compile and execute:
- Download quadratic.cpp.
- Open the terminal or command line and navigate to the directory where the downloaded file resides.
- Run the following commands to compile and execute the program:
g++ quadratic.cpp -o quadratic
./quadratic