/*CSEMATTER.BLOGSPOT.IN
PROGRAM:C PROGRAM FOR STRASSEN'S MATRIX MULTIPLICATION*/
#include<stdio.h>
#include<conio.h>
void main()
{
int arr1[2][2],arr2[2][2],i,j,p1,p2,p3;
int p4,p5,p6,p7,r,s,t,u,a,b,c,d,e,f,g,h;
clrscr();
printf("enter the elements of matrix1\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("enter the value of a[%d][%d]",i,j);
scanf("%d",&arr1[i][j]);
}}
printf("enter the elements of matrix2\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("enter the value of a[%d][%d]",i,j);
scanf("%d",&arr2[i][j]);
}}
a=arr1[0][0];
b=arr1[0][1];
c=arr1[1][0];
d=arr1[1][1];
e=arr2[0][0];
f=arr2[0][1];
g=arr2[1][0];
h=arr2[1][1];
p1=(a*f)-(a*h);
p2=(a+b)*h;
p3=(c+d)*e;
p4=(g-e)*d;
p5=(a+d)*(e+h);
p6=(b-d)*(g+h);
p7=(a-c)*(e+f);
r=p5+p4-p2+p6;
s=p1+p2;
t=p3+p4;
u=p5+p1-p3-p7;
printf("%d\t %d\n %d \t %d",r,s,t,u);
getch();
}
/*OUTPUT
enter the elements of matrix1
enter the value of a[0][0] 1
enter the value of a[0][1] 3
enter the value of a[1][0] 5
enter the value of a[1][1] 7
enter the elements of matrix2
enter the value of a[0][0] 8
enter the value of a[0][1] 4
enter the value of a[1][0] 6
enter the value of a[1][1] 2
26 10
82 34
*/
No comments:
Post a Comment