# Counting the number of times a loop has run

• 04-07-2006
CConfusion
Counting the number of times a loop has run
I need to know how many times the following loop was run and have no clue: ( I need to know how many "v"s I have calculated)

Code:

```                for (i = 0; i <= D; ++i) //Counting up by one for duration/burnrate values { float m, v = vi, h = 500;  //Find t for h = 0.0, set as td         // Must initialize v to the initial velocity ( like v = 0) m = masschange(duration[i], burnrate[i], total); for (j = 0; j <= duration[i]; j = j + tstep)        // j keeps track of the amount of time each duration has run for {                                                               a = ((m*G) - (burnrate[i]*ve))/m;                                 v = v - (a*tstep);        // Like ++v, but with something else +'ing                                       printf("%.3f\n", v); fprintf(outFile, "%.3f\n", v);        // Calculates the nth velocity h = h - (v*tstep); printf("\t%.3f\n", h); //Check to see if the height is going to 0 if (h <= 0)                // Stops when h = 0. {   return 1; }                         } }```
• 04-07-2006
Salem
> v = v - (a*tstep); // Like ++v, but with something else +'ing
So increment something then, say
numOfVsCalculated++;