A quadratic or second degree equation has the following mathematical syntax:
Image may be NSFW.
Clik here to view.
where x is the variable, and a,b,c are user defined constant numbers.
The following code will solve the quadratic equation and will return the solution if the results are integers:
#include
#include
void main()
{ cin>>a; cin>>b; cin>>c;
delta = b*b-4*a*c;
if (delta<0) cout<<”The solution is not an integer”;
else { x1=(-b+sqrt(delta))/(2*a); x2=(-b-sqrt(delta))/(2*a);
cout<< x1<
The post Quadratic (second-degree) equation in C++ (CPP) appeared first on BorlandC.org.