hello everyone, i'm trying to generate a root for a polynomial of order 10 using the Newton Raphson Method...

my ten order polynomial is in the form: P(x) = a0 + a1x + a2x2 + a3x3+ ... + a10x10

my first estimate is 1.5 and the iterations should continue until the difference between the two successive estimates is less than the acceptable error margin which is 0.0000001 or if it exceeds 70 iterations.....

here's my code sofar, though it still has a few issues...

Code:

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define H 0.00000001
#define exit
//Initialize variables
float f(float);
float df(float);
void readf();
float *p;
int n=10;
//Main Function
void main()
void readf()
{
float x=1.5, t, root, It=70;
int count =1;
p=(float *)malloc((n+1)*sizeof (float));
if (fabs(f(x))&&It==H)
{
root=x;
{
while(1)
{
t=x-f(x)/df(x);
//Output Iterattions
if(count && It==70)
printf("\nIteration %d",count);
else
printf("\nThe iterations are too many");
exit
printf("\nFor x%d -> %f, f(x%d) -> %f\n\n",count,t,count,f(t));
if (count%70==0)
{
printf("\n\nEnter any Key to proceed");
}
if(fabs((x-t)/t)&&It==H)
{
root=t;
break;
}
else
x=t;
count++;
}
}
printf("\n\nThe root of the equation is %f\n",root);
printf("\n\nThe total number of iterations is %d",count);
free(p);
}
int i;
for(i=n;i&>=0;i--)
{
printf("Enter coefficient of a^%d",i);
scanf("%f",p+i);
}
printf("Polynomial equation entered\n\n");
for(i=n;i&>=0;i--)
if(*(p+i)!=0)
{
printf("=0\n");
}
float f(float x);
{
int i
float sum=0;
for(i=n;i&>=0;i--)
sum+=*(p+i)*pow(x,i);
return sum;
}
float df(float x);
{
return ((f(x+H)-f(x))/H);
}