Professional Documents
Culture Documents
Fork Liberary
Fork Liberary
Fork Liberary
#include<time.h>
#include<stdlib.h>
#include<stdio.h>
/* length of the matrix */
#define N 1024
/* Array dec */
int C[N][N],A[N][N],B[N][N];
initialize(A);
initialize(B);
/* for present time */
t = clock();
/* call add method */
Add(C,A,B);
/*for time calculation */
t = clock() - t;
double time_taken = ((double)t)/CLOCKS_PER_SEC; // in seconds
/* print to display what time it will take */
printf("TIME TO ADD TWO MATRIX OF SIZE %d IS= %f \n", N,time_taken);
/* call sub method */
sub(C,A,B);
/*for time calculation */
t = clock() - t;
time_taken = ((double)t)/CLOCKS_PER_SEC; // in seconds
/* print to display what time it will take */
printf("TIME TO SUBTRACT TWO MATRIX OF SIZE %d IS= %f \n", N,time_taken);
/* call mul method */
multi(C,A,B);
/*for time calculation */
t = clock() - t;
time_taken = ((double)t)/CLOCKS_PER_SEC; // in seconds
/* print to display what time it will take */
printf("TIME TO MULTPLY TWO MATRIX OF SIZE %d IS= %f \n", N,time_taken);
return 0;
}