Notizen
Ohne Titel
Inhalt der Notizen (1)
Seite 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;
}
Informationen
- Beschreibung
- 4 Computer Science Notiz am Ohne Titel, erstellt von andre jean-bapti am 08/06/2016.
- Erstellt von
- andre jean-bapti · Jun 2016
- Aktualisiert
- 9 Jun 2016
- Aufrufe
- 0
- Bewertung