Hi,
Könnte mir bitte jemand sagen, wie ich eine Wurzel in C++ ziehe?
(steht nicht in meinem Buch und ich bräucht das eben für ein tool )
Hi,
Könnte mir bitte jemand sagen, wie ich eine Wurzel in C++ ziehe?
(steht nicht in meinem Buch und ich bräucht das eben für ein tool )
*Haftungsausschluss*
*People-I-Respect-Table*
Wenn du die Headerdatei Math.h includierst steht dir folgende Methode fürs Quadratwurzel ziehen eines Fließkommawertes zur Verfügung:
double sqrt(double a);
falls du einen completen code willst :
mfg exoCode:#include <iostream.h> #include <conio.h> #include <math.h> int main() { double zahl; cin>>zahl; zahl=sqrt(zahl); cout<<zahl; getch(); }
falls du tiefer in die materie einsteigen willst, das lesen: http://www.matheboard.de/archive/16457/thread.html
MfG RiDER
oder du bist primitiv und machst es so^^
Code:#include<iostream.h> #include<conio.h> void main() { long double zahl1, zahl2, zahl3; int zahl4, zahl5; for(;;) { clrscr(); zahl2=0; zahl3=0; zahl4=0; zahl5=0; cout<<"created by IVI4US4\n\n\nGib bitte eine Zahl ein oder zum Beenden \"0\":\n"; cin>>zahl1; if(zahl1==0) { break; } if(zahl1<0) { zahl1=zahl1*-1; zahl5++; } for(;;) { if(zahl2*zahl2==zahl1) { break; } if(zahl2*zahl2>zahl1) { zahl4++; if(zahl4==15) { break; } zahl2=zahl2-zahl3; zahl3=zahl3/10; } zahl2+=zahl3; } if(zahl5==2) { cout<<"Die Wurzel aus "<<zahl1*-1<<" ist "<<zahl2<<"i\n"; } if(zahl5==1) { cout<<"Die Wurzel aus "<<zahl1<<" ist "<<zahl2<<endl; } getchar(); }}
der geht nicht -.-
hast ein fehler drine