ECE 2305 – Introduction to C Programming
Programming Project 02
Quadratic Equation Solver
Program Features: Branch structure, variables, data input and output, mathematical
operators, function calls.
Design a C++ application that calculates and displays all solutions to quadratic algebraic
equations of the form
𝑎𝑥 2 + 𝑏𝑥 + 𝑐 = 0
with real-numbered values of the constant coefficients a, b and c entered by the user. Your
application should rely on the standard quadratic formulas:
−𝑏 + √𝑏 2 − 4𝑎𝑐
𝑥1 =
2𝑎
−𝑏 − √𝑏 2 − 4𝑎𝑐
𝑥2 =
2𝑎
Structure the program as shown in the following Flow Chart. It is recommended that you
perfect the structure of the program before including the calculations.
Start
Prompt user for a, b and c.
Y a == 0 N
Y b == 0 N Y b2–4ac N
> 0
Y b2–4ac N
“No solution.”
== 0
“One real solution.”
“Two real equal solutions.”
“Two real unequal solutions.”
“Two complex conjugate solutions.”
Following a common practice among electrical engineers, use the symbol j in your display
to represent the square root of –1.
Document the program with the following sections:
A. A brief written description of the purpose of the program including the inputs, the
outputs and a description of the structure of the programming.
This program will take three inputs for A B and C. it will then plug them into a quadratic
equation to find the solutions of the problem. It will use if else statements to filter out unreal
solutions, and find what type of solutions are in the equation. It will then find the solutions
if applicable.
B. A flowchart including all of the equations for the various solutions.
Start
Prompt user for a, b and c.
Y N
a == 0
Y N Y N
b == 0 b2–4ac
> 0
Y N
“No solution.” b2–4ac
== 0
“One real solution.”
Display x = -c/b “Two real equal solutions.”
Like x intercept of Display one part of quadratic equation
y = mx + b
“Two real unequal solutions.”
Display both versions of quadratic
equation
“Two complex conjugate solutions.”
Make b^2 – 4ac positive and then display
both solutions with j at the end
C. The code listing.
D. Screen capture images showing the operation of the program for each of the possible
solutions.
No Solution:
One Real Solution:
Two Real Equal Solutions:
Two Unequal Real Solutions:
Two Complex Conjugate Solutions:
Submit the documentation in a PDF document on Blackboard.