how to find time consumed for sorting a given array[sorted/unsorted]

here is the my code[quick_sort),plz point the errors,remove the errors plz
i want run this programme in fedora also[what exactly the header file would be to find time consumed for sorting a given array[sorted/unsorted]
..........................................................
#inlcude<stdio.h>
#include<conio.h>
#include<time.h>
Const int MAX=1000;
Int partition(int a[],low,int high)
{
Int I,j,,temp,key;
Key=a[low];
I=low;
J=high+1;
While(i<=j&& key<=a[i]);
{
i++;
}
While(key>a[j]);
{
j--;
}
If(i<j)
{
temp=a[i],a[i]=a[j],a[j]=temp;
}
Else
{
Temp=a[low],a[low]=a[j],a[j]=a[low;
Return j;
}
}

Void quick_sort(int a[],int low,int high)
{
Int mid;
If(low<high)
{
mid=partition(a,low,high);
quick_sort(a,low,mid-1);
quick_sort(a,mid+1,high);
}
}

Void main()
{
Int a[MAX],n,I;
Clock_t end,start;
Start=clock();
Printf(“enter the no of elements:”);
Scanf(“%d”,&n);
Printf(“\n enter the elements to sort\n”);
for(i=0;i<=n:i++);
scanf(“%d”,&a[i]);
quick_sort(a,0,n-1);
end=clock();
printf(“\n the sorted elemetns are:\n\n”(;
for(i=0;i<=n:i++);
printf(“%d\t”,a[i]);
printf(“\n\n time consumed the array is: %5.2f sec”,(end-start)/CLK_TCK);
getch();
}
(end-start)/CLK_TCK is an integer quantity, you need to convert it to a double somehow.

Try (end-start)/(double)CLK_TCK instead.
Topic archived. No new replies allowed.