Apuntes
Sin título
Contenido del apunte (1)
Página 1
// Write a C++ program to compute the real roots of the equation: ax2+bx+c=0.
#include
#include
using namespace std;
int main()
{
double a, b, c, x, last;
cout<<"Input 3 Values \n";
cin>>a>>b>>c; //a=2, b=5, c=3
if(a == 0 && b == 0) {
cout<<"no solution"< else if(a == 0) {
cout<<"one root: "<<-b/c< else {
last = b*b-4*a*c;
if(last < 0) {
cout<<"No roots \n"; }
else { cout<<"Roots: "<<-b+sqrt(b*b-4*a*c)/(2*a)<<
",x1= "<<-b-sqrt(b*b-4*a*c)/(2*a); }
}
system("pause");
return 0;
}
Información
- Descripción
- 4 Computer Science Apunte sobre Sin título, creado por andre jean-bapti el 08/06/2016.
- Creado por
- andre jean-bapti · jun 2016
- Actualizado
- 9 jun 2016
- Visitas
- 0
- Valoración