Professional Documents
Culture Documents
Version 3:
#include <stdio.h>
#include <time.h>
void swap(int*,int*);
int main()
{
clock_t begin, end;
int a=10,b=20;
double ts;
begin=clock();
printf("Before Swap a=%d b=%d\n",a,b);
swap(&a,&b);
printf("After Swap a=%d b=%d\n",a,b);
end =clock();
ts=(double)(end-begin)/CLOCKS_PER_SEC;
printf("The total time taken for execution is %f\n",ts);
return 0;
}
void swap(int *x, int *y)
{
int t;
t=*x;
*x=*y;
*y=t;
}
Version 4:
Gates.
#include <stdio.h>
#include <time.h>
void swap(int,int);
int main()
{
clock_t begin, end;
int a=10,b=20;
double ts;
begin=clock();