Hallo Leute,
wiedermal ein C++ Problem.
Und zwar habe ich ein Programm geschreiben, das mit Hilfe der Intervallschachtelung die Wurzel einer Zahl berechnen soll. Folgendes:
Code:
#include <iostream>
using namespace std;
int main (int argc, char * const argv[]) {
int a, b, c;
double d, e;
cout << "Zahl eingeben, aus der die wurzel gezogen werden soll: ";
cin >> a;
cout << "Geschätztes Intervall eingeben; von: ";
cin >> b;
cout << " , bis: ";
cin >> c;
d=(b+c)/2;
e=d*d;
while (e!=a ) {
if (e<=a ) {
d=(d+c)/2;
e=d*d;
}
if (e>=a ) {
d=(d-c)/2;
e=d*d;
}
}
cout << "Die Wurzel aus " << a << "ist" << d ;
}
Mein Problem ist, dass die Schleife nicht ausgeführt wird. Es kommt kein Compiler-Fehler. Aber sobald ich b und c eingegebe kommt keine Reaktion.
Findet jemand den Fehler?