Wurzel
-
^^verstehe...und wo sehe ich was alles in der header drinsteht?
-
Öffnen oder nach ner Referenz googeln.
-
und was stimmt hier nun wieder nicht?!
#include <iostream> #include <cmath> using namespace std; int main() { int intEingabe; cout<<"Geben Sie eine Zahl ein: \t"; cin>>intEingabe; int intAusgabe=sqrt(intEingabe); cout<<"Die Wurzel ihrer Zahl betraegt: \t"<<intAusgabe; system("PAUSE"); return EXIT_SUCCESS; }
-
Funktioniert bei mir einwandfrei. Fehlermeldung?
-
ja fehler...
beim kompilieren
ka warum...aber guck´s dir doch selbst an!
-
#include <iostream> #include <cmath> using namespace std; int main() { int intEingabe; cout<<"Geben Sie eine Zahl ein: \t"; cin>>intEingabe; double intAusgabe=sqrt(intEingabe); cout<<"Die Wurzel ihrer Zahl betraegt: \t"<<intAusgabe; system("PAUSE"); return EXIT_SUCCESS; }Versuchs damit. Oder - wenn es denn ein Integer sein muss - mit
int intAusgabe=(int)sqrt(intEingabe);
-
nee, also hilft beides nicht...ähnliche fehlermeldung...
wtf....
-
Es gibt eine Wurzelfunktion für floats und für doubles. Dein Compiler kann sich hier nicht entscheiden welche er verwenden soll. Das geht dann so:
sqrt( static_cast<double>(intEingabe) );Gruß
-
Der Compiler weiss nicht ob er intEingabe in einen float, einen double oder einen long double konvertieren soll. Du musst ihm dabei helfen, z.B. so:
double intEingabe;
-
also das funktioniert nun:
#include <iostream> #include <cmath> using namespace std; int main() { int intEingabe; cout<<"Geben Sie eine Zahl ein: \t"; cin>>intEingabe; double intAusgabe= sqrt( static_cast<double>(intEingabe) ); cout<<"Die Wurzel ihrer Zahl betraegt: \t"<<intAusgabe <<"\n\n"; system("PAUSE"); return EXIT_SUCCESS; }geht´s eigentlich noch unkomplizierter?!
-
Bei mir von Anfang an ja. Ansonsten mach es wie niemand sagt und nimm keine Integer sondern nur double.
-
kk alles klar, ty