Saturday, January 26, 2013

Write a C++ program to Solve Quadratic equation

11:51 AM

Quadratic equation

Write a program that calculates the real solution of the quadratic equation ax²+bx+c=0
Read in the values for the parameters a,b,c(type float).
Then the program should calculate the solution considering the following circumstances:
a=0andb=0=>Not a valid equation
a=0 and b≠0 => x=-c/b
b² -4ac < 0 => Not a Real Solution
b² -4ac >0 => x1= (-b+√(b² -4ac))/2a , x1= (-b -√(b² -4ac))/2a
Hint:The c++ function for √x is sqrt(x).
To use this function you need to includemath.has a header file#include<math.h>

Solution-


#include<iostream>
#include<cmath>
#include<cstdlib>
#include<cstring>
using namespace std;
int main()
{
double a,b,c,x1,x2;
char x;
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<<"the quadratic equation is"<<a;
cout<<"*x*x+"<<b;
cout<<"*x+"<<c<<endl;
if

(a==0 && b==0)
cout<<"not a valid equation";
if

(a==0 && b!=0)
{
x1=-(c/b);


cout<<endl;
cout<<"root="<<x1;
cout<<endl;
}
if ((b*b-4*a*c)>0)
{
x2=(b*b)-(4*a*c);
x1=-b+sqrt(x2);
cout<<"root="<<x1<<endl;
}
if ((b*b-4*a*c)<0)
{
cout<<"not a real root"<<endl;
}
system("pause");
return 0;
}


Write a C++ program to Solve Quadratic equation






---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------




---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------



Write a C++ program that solves quadratic equation to find its roots
Write a c++ program to solve quadratic equation
C++ quadratic equation solver
Quadratic Equation: C++ Source Code
program to find the roots of a quadratic equation
C program for solving quadratic equation
How do you write a c program to solve quadratic equation

Written by

We are one of the initiators of the development of information technology in understanding the need for a solution that is familiar and close to us.

1 comments:

  1. Write A C++ Program To Solve Quadratic Equation ~ Klick Dev >>>>> Download Now

    >>>>> Download Full

    Write A C++ Program To Solve Quadratic Equation ~ Klick Dev >>>>> Download LINK

    >>>>> Download Now

    Write A C++ Program To Solve Quadratic Equation ~ Klick Dev >>>>> Download Full

    >>>>> Download LINK 49

    ReplyDelete

 

© 2013 Klick Dev. All rights resevered.

Back To Top