سورس برنامه ی حل معادله ی درجه دوم با گرفتن a و b و c:

#include <iostream.h>
#include <math.h>

void main()
{
    int a, b, c;
    int delta;
    cout<<"Please enter a, b, c as this structure: ax^2+bx+c=0"<<endl;
    cin>>a>>b>>c;
    delta = (b*b)-(4*a*c);
    if(delta == 0)
    {
        cout<<"The only answer:\n"<<"x= "<<(-b)/(2*a);
    }
    else if(delta > 0)
    {
        cout<<"Two answers:\n"<<"x1= "<<((-b)+sqrt(delta))/(2*a);
        cout<<"\tx2= "<<((-b)-sqrt(delta))/(2*a);
    }
}


//end