This program is supposed to sort an array of random numbers and print out the time it took for the sort to take place. I'm currently not getting any output. Help would be appreciated.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int swap,temp,i,j,s,a[];
float function_time;
clock_t start;
clock_t end;
int main()
{
printf("Enter total number of elements: ");
scanf("%d",&s);
a[i] = rand()%10000;
for(i=0;i<s;i++)
{
scanf("%d", &a[i]);
}
start = clock();
for(i=1;i<s;i++)
{
temp=a[i];
j=i;
for(j=i-1;j>=0 && a[j]>temp; j--)
{
a[j+1]=a[j];
}
a[j+1]=temp;
}
end = clock();
function_time = (float)(end-start)/(CLOCKS_PER_SEC); // Time in seconds
printf("\nTime for Insertion Sort is %f seconds\n", function_time);
}