Loops can be turned into tail recursion really easy
Code:
#include <stdio.h>
#define N 7
void InsertionSort(int i, int array[], int size)
{
if (i < size)
{
int j;
int temp = array[i];
for (j = i; j > 0 && array[j-1] > temp; j--)
array[j] = array[j-1];
array[j] = temp;
InsertionSort(++i, array, size);
}
}
int main(void)
{
int p;
int array[N] = {37,23,17,12,72,31,46};
InsertionSort(0, array, N);
printf("The list of sorted numbers is\n");
for (p = 0; p < N; p++)
printf("%d ",array[p]);
printf("\n\n");
return 0;
}
And don't use void main, it's not valid C for a hosted implementation. In other words, if you use an operating system then main only returns an int, if you *are* the operating system, you can do what you want.