nevermind my last posting.... got another problem....
program compiles without problems and seems to work correctly... but the uotput is totaly wrong most of the times...
the problem is, that the program is not using decimal numbers even if i declared them as float...
Code:
#include <stdio.h>
#include <math.h>
int main()
{int grad=0;
double ergebnis=0;
double ableitung=0;
float x=0;
int i=0;
int k=0;
int l=0;
printf ("Dieses Programm berechnet den Funktionswert sowie die erste Ableitung eines beliebigen Polynoms aus\n");
printf ("Geben sie den Grad des Polynoms ein!\n");
scanf ("%d", &grad);
float vielfache[grad+1];
for (i<grad; i++;)
{vielfache[i]=0;}
i=0;
while (k < grad+1 )
{printf ("Geben sie das %i . Vielfache des Polynoms ein!\n" ,k+1);
scanf ("%f", &vielfache[i]);
//printf ("%f %d \n" , vielfache[i] , i);
k++;
i++;}
i=0;
k=0;
printf ("Geben sie einen Wert für x ein!\n");
scanf ("%f", &x);
double zwischenwert[grad+1];
for (l<2*grad; l++;)
{zwischenwert[l]=0;}
l=0;
while (i<grad+1)
{zwischenwert[l]=vielfache[i]*x;
i++;
zwischenwert[l+1]=zwischenwert[l]+vielfache[i];
ergebnis=zwischenwert[l+1];
//printf ("%g %g %g \n" , ergebnis , zwischenwert[l], x);
l++;
l++;
i++;}
printf ("Der Funktionswert des Polynoms ist: %f \n" ,ergebnis);
i=0;
l=0;
while (i<grad)
{zwischenwert[l]=vielfache[i]*grad*x;
i++;
zwischenwert[l+1]=zwischenwert[l]+vielfache[i];
ergebnis=zwischenwert[l+1];
l++;
l++;
i++;}
ableitung=ergebnis/x;
printf ("Die erste Ableitung des Polynoms ist: %f \n" ,ableitung);
return 0;
}
can someone explain why this happens and how to fix it? thank u very much