1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
#include <stdio.h>
#include <stdlib.h>
int multiplydisplay_array(int firstarray, int secondarray, int i, int j,int k, int sum)
int main(void)
{
int firstarray[5][5];
int secondarray[5][5];
int firstbysecond[5][5];
int i;
int j;
int k;
int sum;
for (i=0; i<5; i++)
{
for (j=0; j<5; j++)
{
printf("Enter an element for the first array:\n");
scanf("%d", &(firstarray[i][j]));
}
}
for (i=0; i<5; i++)
{
for (j=0; j<5; j++)
{
printf("Enter an element for the second array:\n");
scanf("%d", &(secondarray[i][j]));
}
}
multiplydisplay_array(firstarray, secondarray, firstbysecond, i, j, k, sum);
system("pause");
return;
}
int multiplydisplay_array(int firstarray, int secondarray,int firstbysecond, int i,int j,int k,int sum)
{
for (i=0; i<5; i++)
{
for (j=0; j<5; j++)
{
sum=0;
for (k=0; k<5; k++)
{
sum += firstarray[i][k] * secondarray[k][j];
}
firstbysecond[i][j]=sum;
}
}
printf("The first matrix multiplied by the second matrix is the matrix:\n");
for (i=0; i<5; i++)
{
for (j=0; j<5; j++)
{
printf("\t %d",firstbysecond[i][j]);
}
printf("\n");
}
return (firstbysecond);
}
|