Looking for NEET / JEE Coaching? Enquire Now
• # Write a C program to add two 3 x 3 matrices

Are you preparing for Diploma MSBTE exam? Looking out for a program solution for addition of two matrices? Our ISC experts shall provide you a program solution on this page to solve the problem.

Following is a question that was asked in the question paper of Diploma in Electronics and Telecommunication Engineering (Summer 2019)conducted by MSBTE Mumbai, for subject C Programming (22218).

This question is asked for 6 marks and hence requires some explanation along with the program code. Please let me know the solution.

Q) Write a program to add two 3 × 3 matrices. [6 Marks]

• Two dimensional array represents matrix structure. In two dimensional array first dimension represents row and second dimension represents column.
e.g. int mat;
In above example mat is name of array which holds all integer values. This array holds total 6 integers. In above declaration first dimension which is 2 which represents row and second dimension which is 3 that represents columns and hence this array has two rows and each row has three columns.
In case of two or more dimensional array user have to use loop for accepting the array elements, processing array elements or outputting array elements. In general for every purpose user have to use loop.
Below is the program to add two 3 x 3 matrices.
Please include stdio.h and conio.h before main function.
#include
#include
void main(void)
{
clrscr();
printf("Enter first matrix elements(any 9 numbers)\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&m1[i][j]);
}
}
printf("Enter second matrix elements(any 9 numbers)\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&m2[i][j]);
}
}
printf("\n************************************************************\n");
printf("Resultant matrix is as follows\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{