F
Fan Zhang
Dear group,
I wrote a simple code trying to use the integer index of a "for" loop inside
the loop. The idea is to convert it to double type and lead it into a
function. However it appears I can't call the integer number directly inside
the loop, otherwise, the results are not sensible.
The code is as the following,
int main()
{
int i;
double min, max,modl,tt;
max=PI/2;
for (i=1;i<=90;i++)
{
9---> min=i/radian;
modl=background+Gaussian_quadrature(max,min);
printf("%d \t %6.4f \n",i,modl);
tt=tt+1.;
}
system("pause");
return 0;
}
I tried min= (double)i/radian in line 9 as well. It does not give the right
result either. Eventually, I defined another variable tt, initialized it to
be 1 outside of the loop and increased it by one per loop. I want to know
why I could not use the index inside loop. Thanks!
Fan
I wrote a simple code trying to use the integer index of a "for" loop inside
the loop. The idea is to convert it to double type and lead it into a
function. However it appears I can't call the integer number directly inside
the loop, otherwise, the results are not sensible.
The code is as the following,
int main()
{
int i;
double min, max,modl,tt;
max=PI/2;
for (i=1;i<=90;i++)
{
9---> min=i/radian;
modl=background+Gaussian_quadrature(max,min);
printf("%d \t %6.4f \n",i,modl);
tt=tt+1.;
}
system("pause");
return 0;
}
I tried min= (double)i/radian in line 9 as well. It does not give the right
result either. Eventually, I defined another variable tt, initialized it to
be 1 outside of the loop and increased it by one per loop. I want to know
why I could not use the index inside loop. Thanks!
Fan