Heap Sort Implementation example program in c

Heap sort is a very famous sorting technique relying on building heaps. It runs in O(nLogn).
#include<stdio.h>
#define SWAP(x,y)  int t;t=x;x=y;y=t;
void print_array(int a[],int len){
	int i;
	for(i=0;i<len;i++)printf("%d ",a[i]);
}
void heap_sort(int a[],int len)
{
	int i,j,root,c;
	/* Heap Sort runs in O(nLogn) */
	for(i=0;i<len;i++)
	{
		//do max heapify for array 0 to len-i-1
		for(j=len-i-1;j>0;j--)
		{
			root = (j - 1) / 2 ;
			c = a[j] > a[j-1] ? j : j - 1 ; 
			if(a[root] < a[c])
			{
				SWAP(a[root],a[c]);
			}
		}
		SWAP(a[0],a[len-i-1]);
		printf("\nArray after %d iteration\n",i+1);
		print_array(a,len);
	}
}
int main(){
	/* The initial unsorted array */
	int a[] = {6,3,5,9,2,7,4,8,1} ;
	int len ;
	len = sizeof(a)/sizeof(int);
	heap_sort(a,len);
	printf("\nSorted Array\n");
	print_array(a,len);
	return 0;
}