Search Your Query

Custom Search

Tuesday, 24 May 2011

Quadratic Formula Program


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

float x=0,y=0;

void quad(float a, float b, float c)
{
    float d;
    d = float (sqrt(b*b-4*a*c));
    x = (-b+d) / (2*a);
    y = (-b-d) / (2*a);  
}

void main()
{
    float a,b,c;

    cout << "Implementation of quadratic farmula:" << endl;
    cout << "Enter the values of a,b and c and you will get the values of x." << endl << endl;

    cout << "Enter the value of a : "; cin >> a;
    cout << "Enter the value of b : "; cin >> b;
    cout << "Enter the value of c : "; cin >> c;
    cout << endl;

    quad(a,b,c);

    cout << "x = { "<< x << " , " << y << " } " << endl;
//    cout << endl << "Thank You!" << endl;

}

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...