-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcuadratica.cpp
More file actions
34 lines (28 loc) · 785 Bytes
/
cuadratica.cpp
File metadata and controls
34 lines (28 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
#include <math.h>
using namespace std;
int a, b, c;
double solucion1(int a, int b, int c){
double salida = (-b+sqrt(pow(b, 2)-4*(a)*(c)))/2*a;
return salida;
}
double solucion2(int a, int b, int c){
double salida = (-b-sqrt(pow(b, 2)-4*(a)*(c)))/2*a;
return salida;
}
main(){
while (true){
cout << "Ingrese el valor de a: ";
cin >> a;
cout << "Ingrese el valor de b: ";
cin >> b;
cout << "Ingrese el valor de c: ";
cin >> c;
// if (solucion1(a, b, c) != nan and solucion2(a, b, c) != nan){
cout << "La solucion 1 de la ecuacion es: " << solucion1(a, b, c) << endl;
cout << "La solucion 2 de la ecuacion es: " << solucion2(a, b, c) << endl;
// } else {
// cout << "La ecuacion no tiene solucion en los reales." << endl;
// }
}
}