Bubble Sort

Bubble Sort is the first sorting algorithm for any beginner. Bubble Sort runs in O(n2) time. The algorithm makes maximum number of comparisions which is n(n - 1)/2. The algorithm makes n(n-1)/2 swaps in worst case as the compared elements are swapped among themselves. The Code:
#include<stdio.h>
void bubble_sort(int a[],int len)
{
	int i,j,k,temp;
	/* Bubble Sort runs in O(n2) */
	for(i=0;i<len;i++){
		for(j=0;j<len-1-i;j++)
		{
			if(a[j]>a[j+1]) 
			{
				/* swap a[j] with a[j+1] */
				temp = a[j];
				a[j] = a[j+1];
				a[j+1] = temp;
			}
		}
		printf("\nArray after %d iteration\n",i+1);
		print_array(a,len);
	}
}
void print_array(int a[],int len){
	int i;
	for(i=0;i<len;i++)printf("%d ",a[i]);
}
int main(){
	/* The initial unsorted array */
	int a[] = {6,3,5,9,2,7,4,8,1} ;
	int len ;
	len = sizeof(a)/sizeof(int);
	bubble_sort(a,len);
	printf("\nSorted Array\n");
	print_array(a,len);
	return 0;
}