Tuesday, November 13, 2012

Quadratic equation in C++

#include <iostream>
#include <conio.h>
#include <math.h>
using namespace std;
int main()
{
        int a,b,c,d,e,i;
        cout<<"Solving the quadratic equation ax^2+bx+c=0"<<endl;
        cout<<"Enter 'a' value:";
        cin>>a;
        cout<<"Enter 'b' value:";
        cin>>b;
        cout<<"Enter 'c' value:";
        cin>>c;
        i=1/2;
        d=(b*b)+4*(a*c);
        e=sqrt(d)/2*a;
        cout<<endl<<"The values of x are"<<-b+e<<" and "<<-b-e;
        getch();
        return 0;
}

No comments:

Post a Comment