Counting repeating operations

Hey,
Is it possible to count how many times a repeating operation has happend?

For example
1
2
while (a>3)
a = a-b;


Would it be possible for the program to count how many times b is taken from a before a>3?

Thanks
Sure:

1
2
3
4
5
6
int count = 0; //Make a variable to keep track of the number of times the operation was performed.
while (a>3)
{
    a = a-b;
    count++; //Increment count each time the operation was performed.
}
Topic archived. No new replies allowed.