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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
|
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10][10],b[10][10],c[10][10],m,n,m1,n1;
int i,j,k,ch;
clrscr();
printf("Enter The Order of Matrix A : ");
scanf("%d%d",&m,&n);
printf("Enter The Values for Matrix A:\n");
for(i=0;i<=m;i++)
{
for(j=0;j<=n;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("\nEnter The Order of Matrix B : ");
scanf("%d%d",&m1,&n1);
printf("\nEnter The Values for Matrix B.");
for(i=0;i<=m1;i++)
{
for(j=0;j<=n1;j++)
{
scanf("%d",&b[i][j]);
}
}
while(1)
{
printf("\nt\Matrix Manipulation");
printf("\n\t\t-------------------------\n");
printf("\n1.matrix addition");
printf("\n2.matrix substraction");
printf("\n3.matrix multiplication");
printf("\n4.matrix transpose");
printf("\n5.exit\n");
printf("Enter your choice:");
scanf("%d",&ch);
switch(ch)
{
case 1:
if((m==m1)&&(n==n1))
{
printf("\nSum of the given Two Matrixes is:\n");
for(i=0;i<=m1;i++)
{
for(j=0;j<=n1;j++)
{
c[i][j]=a[i][j]+b[i][j];
printf("%d ",c[i][j]);
}
printf("\n");
}
}
else
printf("Addition is Not Possible");
break;
case 2:
if((m==m1)&&(n==n1))
{
printf("\n Difference Of the given Two Matrices is:\n");
for(i=0;i<=m1;i++)
{
for(j=0;j<=n1;j++)
{
c[i][j]=a[i][j]-b[i][j];
printf("%d ",c[i][j]);
}
printf("\n");
}
}
else
printf("Subtraction is Not Possible");
break;
case 3:
if(m1==n)
{
for(i=0;i<=m;i++)
{
for(j=0;j<=n;j++)
{
c[i][j]=0;
for(k=0;k<=n;k++)
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
}
printf("\n The Product of the given Matrix is:\n");
for(i=0;i<=m;i++)
{
for(j=0;j<=n;j++)
{
printf("\t%d ",c[i][j]);
}
printf("\n");
}
}
else
printf("\n The product is Not Possible");
break;
case 4:
for(i=0;j<n;i++)
{
for(j=0;j<m;j++)
{
c[i][j]=a[j][i];
} }
printf("The transpose of the given Matrix is:\n");
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
printf("%d \t ",c[i][j]);
printf("\n");
}
break;
case 5:
exit(0);
break;
}
getch();
}
}
|