Question: How would I implement a function with its arguments changing in a loop?

i.e. I would like to be able to implement the function in the form:

```
f( A[0], A[1], A[2] );
f( A[2], A[0], A[1] );
f( A[1], A[2], A[0] );
f( A[0], A[1], A[2] );
f( A[2], A[0], A[1] );
f( A[1], A[2], A[0] );

```

I got as far as being able to create the numbers in the correct place with the program below, tested using the printf() function:

```c
#include <stdio.h>

int main()
{
    int i, j, k, l;

    for(i = 0; i < 2; i++)
    {
        for( j = 0; j < 3; j++ )
        {
            for( k = 0; k < 3; k++ )
            {
                l = k - j;
                if( l < 0)
                    l += 3;
                printf("%d", l);
            }
            printf("\n");
        }
    }
}

```

Answer: 
If I understand your question correctly, all you need is:

```
int i;
for (i = 0; i < NUM_CALLS; i++)
    f(A[(2 * i) % 3], A[(2 * i + 1) % 3], A[(2 * i + 2) % 3])  

```
All you're missing is `f( A[i], A[j], A[k] );` in the inner-most loop.