Bu kodun neresinde yanlışlık var sizce?
#include<stdio.h>
#include<math.h>
double fonks(int x)
{
int denklem,t;
double equation;
printf("Enter the right equation\n");
printf("1 for the first equation\n");
printf("2 for the second equation\n");
printf("3 for the third equation\n");
printf("4 fot the fourth equation\n");
printf("5 for the fifth equation\n");
scanf("%d",&denklem);
t=x*3,141593/180;
switch(denklem)
{
case 1:
{
equation=pow(x,7)+4*pow(x,3)+12;
break;
}
case 2:
{
equation=log(x)-exp(-3*x);
break;
}
case 3:
{
equation=cos(x)-pow(x,2);
break;
}
case 4:
{
equation=exp(sin(t))+x;
break;
}
case 5:
{
equation=log10(1+x)-pow(x,2);
break;
}
default:
{
printf("Undefined equation.");
break;
}
}
return equation;
}
int main()
{
int i;
double h=0.001,epsilon=0.0000001,x_initial=0.5;
double x[50];
for(i=0;i<=49;i++)
{
x[0]=0.5;
x[i+1]=x[i]-((fonks(x[i])*h)/(fonks(x[i]+h)-fonks(x[i])));
if(fabs(x[i+1]-x[i])<epsilon)
{
printf("%.10f\n",x[i]);
break;
}
}
return 0;
}