Array Multiplication:
Solution:
#include<conio.h>
#include<stdio.h>
void main()
{
int a[25][25],b[25][25],c[25][25],i,j,m,n,o,k;
clrscr();
printf("\nEnter row & column in A:\n");
scanf("%d\n%d",&m,&n);
printf("\nEnter the column value in B:\n");
scanf("%d",&o);
printf("\nEnter %d*%d value of A\n",m,n);
for(i=0; i< m; i++)
for(j=0; j< n; j++)
scanf("%d",&a[i][j]);
printf("\nEnter %d*%d value of B\n",n,o);
for(i=0; i< n; i++)
for(j=0; j< o; j++)
scanf("%d",&b[i][j]);
printf("\nA values:\n");
for(i=0; i< m; i++)
{
for(j=0; j< n; j++)
printf("%d\t",a[i][j]);
printf("\n");
}
printf("\nB values:\n");
for(i=0; i< n; i++)
{
for(j=0; j< o; j++)
printf("%d\t",b[i][j]);
printf("\n");
}
for(i=0; i< m; i++)
for(k=0; k< o; k++)
{
c[i][k]=0;
for(j=0; j< n; j++)
{
c[i][k]=c[i][k]+a[i][j]*b[j][k];
}
}
printf("\nC values:\n");
for(i=0; i< m; i++)
{
for(j=0; j< o; j++)
printf("%d\t",c[i][j]);
printf("\n");
}
getch();
}
Sample Output:
Note:
" Hi I am a Learner of C/C++. I have done this program with my own Knowledge. There may be easy way to solve this programs. So I am sorry if this program in your point of view is too long. "
Solution:
#include<conio.h>
#include<stdio.h>
void main()
{
int a[25][25],b[25][25],c[25][25],i,j,m,n,o,k;
clrscr();
printf("\nEnter row & column in A:\n");
scanf("%d\n%d",&m,&n);
printf("\nEnter the column value in B:\n");
scanf("%d",&o);
printf("\nEnter %d*%d value of A\n",m,n);
for(i=0; i< m; i++)
for(j=0; j< n; j++)
scanf("%d",&a[i][j]);
printf("\nEnter %d*%d value of B\n",n,o);
for(i=0; i< n; i++)
for(j=0; j< o; j++)
scanf("%d",&b[i][j]);
printf("\nA values:\n");
for(i=0; i< m; i++)
{
for(j=0; j< n; j++)
printf("%d\t",a[i][j]);
printf("\n");
}
printf("\nB values:\n");
for(i=0; i< n; i++)
{
for(j=0; j< o; j++)
printf("%d\t",b[i][j]);
printf("\n");
}
for(i=0; i< m; i++)
for(k=0; k< o; k++)
{
c[i][k]=0;
for(j=0; j< n; j++)
{
c[i][k]=c[i][k]+a[i][j]*b[j][k];
}
}
printf("\nC values:\n");
for(i=0; i< m; i++)
{
for(j=0; j< o; j++)
printf("%d\t",c[i][j]);
printf("\n");
}
getch();
}
Sample Output:
Note:
" Hi I am a Learner of C/C++. I have done this program with my own Knowledge. There may be easy way to solve this programs. So I am sorry if this program in your point of view is too long. "
No comments:
Post a Comment
Hello Friends...! Lets share Your Views,Ideas,Comments here....!!