Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Compile and Execute C Online

#include <stdio.h>
int main()
{
    int a[50][50],b[50][50],c[50][50],i,j,k,d[50][50];
    
    printf("enter the elements of 1st matrix\n");
    for (i=0; i<3; ++i)
    {
        for (j=0; j<3; ++j)
        {
        printf("a[%d][%d] = \n",i,j);
        scanf("%d",&a[i][j]);
        }
    }
    printf("enter the elements of 2nd matrix\n");
    for (i=0; i<3; ++i)
    {
        for (j=0; j<3; ++j)
        {
        printf("b[%d][%d] = \n",i,j);
        scanf("%d",&b[i][j]);
        }
    }
	for (i=0; i<3; ++i)
	{
		for (j=0; j<3; ++j)
		{
			c[j][i] = a[i][j];
		}
	}
	for (i=0; i<3; ++i)
	{
		for (j=0; j<3; ++j)
		{
		    d[i][j]=0;
		}
	}
	for (i=0; i<3; ++i)
	{
		for (j=0; j<3; ++j)
		{
		    for (k=0; k<3; ++k)
		    {
		       d[i][j] = d[i][j] + (c[i][k]*b[k][j]) ;
		    }
		}
	}
	for (i=0; i<3; ++i)
	{
		for (j=0; j<3; ++j)
		{
			printf("d[%d][%d] = %d  ",i,j,d[i][j]);
			if (j == 2)
				printf("\n");
		}
	}

    return 0;   
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.