just a simple for loop from 2 to 4(including for with increments 0.1 and 0.01.
the problem is that when the increment is 0.1, the value of cur in last loop is 3.9; wheras, when increment=0.01 it is 4(as expected). all the variables are "double".
any idea or suggestion?
for(cur=alt;cur<=ust;cur=cur+0.1)
{
curf=cur*cur;
printf("cur = %lf, prev=%lf , curf= %lf , prevf=%lf \n", cur,prev,curf,prevf);
trap=(curf+prevf)*(cur-prev)/2;
sum=sum+trap;
prev=cur;
prevf=curf;
}