- #1
jam12
- 38
- 0
Im using the c programming language and just wanted to ask a quick question. In a while loop how do you make the program terminate by printing a value or a message here's my code
while ((fabs(func(x))>epsilon))
{
if(deriv(x)==0) {
print the last value of x and stop the whole program}
else {
y=(func(x)/deriv(x));
x=x-y;
printf("%d\n",iteration);
iteration=iteration+1;
printf("%lf\n",x);
}
}
while ((fabs(func(x))>epsilon))
{
if(deriv(x)==0) {
print the last value of x and stop the whole program}
else {
y=(func(x)/deriv(x));
x=x-y;
printf("%d\n",iteration);
iteration=iteration+1;
printf("%lf\n",x);
}
}
Last edited: