I
Hi,
ich habe hier mal ein Programm für die n-te Wurzel geschrieben.
int wurzel;
float wert2;
printf("die wie vielte wurzel möchten sie ziehen?\n");
fflush(stdin);
scanf("%d", &wurzel);
if(wurzel<0)
casetwo();
do{
printf("welche zahl moechten sie wurzeln :d\n");
fflush(stdin);
scanf("%f", &wert2);
}while(wert2<0);
start=wert2;
ergebnis=heron(wert2, start, wurzel);
printf("die %d. wurzel aus %f ist %f \n", wurzel, wert2, ergebnis);
float heron(float wert, float start, int wurzel)
{
int i=0;
for(i=0;i<100;i++)
{
wert= ((wurzel-1)*potenz(wert, wurzel) + start)/(wurzel*potenz(wert, wurzel-1));
}
ergebnis=wert;
return ergebnis;
}
float potenz(float wert, int wurzel)
{ int i=1;
float pot=1;
for(i=1;i<=wurzel;i++)
{
pot=pot*wert;
}
wert=pot;
return wert;
}