Skip to content

Commit 944b101

Browse files
author
=
committed
Naive matrix multiplication method added
1 parent 016dc6c commit 944b101

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Lab3/a.out

4.01 KB
Binary file not shown.

Lab3/naivemultiplication.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#include<stdio.h>
2+
#include<time.h>
23
int main()
34
{
45
int r1,c1,r2,c2,i,j,k;
6+
clock_t s,e;
7+
float t;
58
printf("Enter the number of rows and columns of first matrix\n");
69
scanf("%d%d",&r1,&c1);
710
int A[r1][c1];
@@ -43,6 +46,7 @@ printf("%d\t",B[i][j]);
4346
printf("\n");
4447
}
4548
printf("For the matrix multiplication process, we need number of columns of A matrix equal to the number of rows of B matrix\n");
49+
s=clock();
4650
if(c1==r2)
4751
{
4852
int C[r1][c2];
@@ -72,5 +76,8 @@ else
7276
{
7377
printf("Matrix multiplication operation is not possible\n");
7478
}
79+
e=clock();
80+
t=(float)(e-s)/CLOCKS_PER_SEC;
81+
printf("Time taken for processing is: %f\n",t);
7582
return 0;
7683
}

0 commit comments

Comments
 (0)