Never use this approach in math calculations: 0.02 is a double type approximation of the real number 0.02 so 100*0.02 != 2.0.
In that case you have 100 intervals (and 101 points):
double t;
int i;
for (t = 0.0,i = 0; i <= 100; ++i, t = i/50.0) {
.....
}
In that case you also have a ready-to-use index to place all needed values in arrays (to plot graph etc)...
To avoid time expensive conversions of i var from int type to double type you can add in the loop header auxiliary double "index" variable. As usually, no need in this optimization...
Reputation Points: 1234
Solved Threads: 347
Postaholic
Offline 2,001 posts
since Jul 2008