Sunday, 21 January 2018

Program for Matrix Multiplaction | Sample program for Matrix |



Program for Matrix Multiplaction
#include<stdio.h>
#include<conio.h>
main()
{
int a[10][10],b[10][10],c[10][10],i,j,m,n,o,p,k;
clrscr();
printf("input the order of A&B matrice's\n");
scanf("%d%d%d%d",&m,&n,&o,&p);
if(n==o)
{
printf("matrice's can be multiplied\n");
printf("input matrix A\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{

scanf("%d",&a[i][j]);
}
printf("\n");
}
printf("input matrix B\n");
for(i=0;i<o;i++)
{
for(j=0;j<p;j++)
{
scanf("%d",&b[i][j]);
}
printf("\n");
}
for(i=0;i<m;i++)
{
for(j=0;j<p;j++)
{
c[i][j]=0;
for(k=0;k<n;k++)
{
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
                        printf("%5d",c[i][j]);

}
printf("\n");
}
}
else
printf("matrice's cannot be multiplied");
getch();
}

Related Posts:

  • Limitations of array Pointers to stringsLimitations of array Pointers to stringsWhen we are using a two-dimensional array of characters we are at liberty to either initialize the strings where we are declaring the array, or receive the stringsusing scanf() function… Read More
  • String Handling Functions In CString Handling Functions In CWith every C compiler a large set of useful string handling library functions are provided. The following figure illustrates the more commonly used functions along with theirpurpose.1.strlen: Fin… Read More
  • Putting Strings TogetherPutting Strings TogetherWe cannot assign one string to another directly We cannot join two strings together by the simple arithmetic addition.       string3 = string1+string2;       str… Read More
  • Programs In String Handling FunctionsPrograms In String Handling Functions1.Is the folowing program correct or not?   yes/nomain(){  char *str1 = "United";  char * str2 = "Front";  char  *str3;  str3 = strcat(str1, str2); … Read More
  • Array Of Pointers To StringsArray Of Pointers To StringsAs we know , a pointer variable always contains an address. Therefore , if we construct an array of pointers it would contain a number of addresses.Let us see how the names in the earlier example c… Read More

0 comments:

Post a Comment