I've written this C prog. (insertion sort) which sorts and finds the time of execution.
#include<stdio. h>
#include<conio. h>
#include<time.h >
main()
{
int a[25] , i , j , k;
clock_t start,end;
clrscr();
printf("\n enter the numbers ");
for( i= 0 ; i <= 24 ; i++)
scanf("%d" , &a[i]) ;
start=clock();
for(i =0 ; i<= 24 ; i++ )
{
for( j= 1 ; j<= 24 ; j++ )
{
if(a[i]> a[j])
{
k = a[i];
a[i]=a[j];
a[j] = k ;
}
}
}
printf("\n sorted numbers are ");
for(i = 0 ; i<= 24 ; i++ )
{
printf("%d" , a[i]) ;
}
end=clock();
printf("\n\nTim e of execution : %f",(end-start)/CLK_TCK);
getch();
}
---------------
my problem is that it always outputs time of execution = 0.000000 whatever i do.
why it is not showing different values ? what changes should i make to this prog?is there any other way to find time of execution ?
#include<stdio. h>
#include<conio. h>
#include<time.h >
main()
{
int a[25] , i , j , k;
clock_t start,end;
clrscr();
printf("\n enter the numbers ");
for( i= 0 ; i <= 24 ; i++)
scanf("%d" , &a[i]) ;
start=clock();
for(i =0 ; i<= 24 ; i++ )
{
for( j= 1 ; j<= 24 ; j++ )
{
if(a[i]> a[j])
{
k = a[i];
a[i]=a[j];
a[j] = k ;
}
}
}
printf("\n sorted numbers are ");
for(i = 0 ; i<= 24 ; i++ )
{
printf("%d" , a[i]) ;
}
end=clock();
printf("\n\nTim e of execution : %f",(end-start)/CLK_TCK);
getch();
}
---------------
my problem is that it always outputs time of execution = 0.000000 whatever i do.
why it is not showing different values ? what changes should i make to this prog?is there any other way to find time of execution ?
Comment