modify this code so that it shows the values of the iteration before the final r
ID: 3917049 • Letter: M
Question
modify this code so that it shows the values of the iteration before the final root is found
#include<stdio.h>
#include<math.h>
float root(float);
int main()
{
float a[100],b[100],c=100.0;
int i=1,j=0;
b[0]=(cos(0)-3*0+1);
printf(" Enter a beginning guess: ");
scanf("%f",&a[0]);
while(c>0.00001)
{
a[j+1]=root(a[j]);
c=a[j+1]-a[j];
c=fabs(c); //fabs = Absolute Value of Floating-Point Number
j++;
}
printf(" The root of the given function is %f",a[j]);
}
float root(float x)
{
float y;
y=(cos(x)+2)/3;
return y;
}