#include <stdio.h>
#include <conio.h>
int main()
{
int m, n, p, q, i, j, k, sum = 0;
int first[10][10], second[10][10], mul[10][10];
printf(" Enter the number of rows and columns of first matrix " );
scanf(" %d %d ", &m, &n );
printf(" Enter the elements of first matrix\n " );
for ( i = 0 ; i < m ; i++ )
for ( j = 0 ; j < n ; j++ )
scanf(" %d ", &first[i][j] );
printf(" Enter the number of rows and columns of first matrix " );
scanf(" %d %d ", &p, &q );
if ( n != p )
printf(" Matrices with entered orders can't be multiplied with each other." );
else
{
printf(" Enter the elements of second matrix\n " );
for ( i = 0 ; i < p ; i++ )
for ( j = 0 ; j < q ; j++ )
scanf(" %d ", &second[i][j] );
for ( i = 0 ; i < m ; i++ )
{
for ( j = 0 ; j < n ; j++ )
{
for ( k = 0 ; k < p ; k++ )
{
sum = sum + first[ i ] [ k ] * second[ k ] [ j ];
}
mul[ i ] [ j ] = sum;
sum = 0;
}
}
printf(" Product of entered matrices:-\n " );
for ( i = 0 ; i < m ; i++ )
{
for ( j = 0 ; j < q ; j++ )
printf(" %d \t ", mul[ i ] [ j ] );
printf("\n");
}
}
getch();
return 0;
}
OUTPUT:
Enter the number of rows and columns of first matrix 2
2
Enter the elements of first matrix
1
5
6
4
Enter the number of rows and columns of second matrix 2
2
Enter the elements of second matrix
1
2
4
6
Product of entered matrices:-
21 32
22 36
ALSO READ:
-- Program To Print First Ten(10) Natural Numbers.
-- Program To Print Fibonacci Series Upto 100.
-- Program To Check Whether A Number Is Prime Or Not.
-- Program To Compute The Reverse Of A Number.
-- Program To Print A Semicolon Without Using A Semicolon.
-- Program To Display Function Without Using The Main Function.
-- Program To Print Any Print Statement Without Using Semicolon.
-- Program To Display Its Own Source Code As Its Output.
-- Program To Swap Two Strings Using strcpy() Function.
-- Program to accept a string and print the reverse of the given string.
-- Program To Get IP Address.
-- Program To Accept An Integer & Reverse It.
-- Program To Convert Given Number Of Days To A Measure Of Time Given In Years, Weeks & Days.
-- Program To Illustrate The Concept Of Unions.
-- Program To Find The Size Of A Union.
... Back To C++ Programs Index
... Back To C++ FAQ's Index
... Back To C Programs Index
... Back To C FAQ's Index
... Back To HR Interview Index
Comments
Post a Comment
Please share your opinions and suggestions or your experience in the comments section. This way we can all help each other...
Experienced guys can share their resumes at admin@interview-made-easy.com