0% found this document useful (0 votes)
5 views1 page

Matrix Add

The document contains a C program that adds two matrices. It prompts the user to input the dimensions and elements of two matrices, computes their sum, and prints the resultant matrix. The program uses nested loops to handle the input and addition of matrix elements.

Uploaded by

Aneez Hassan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Matrix Add

The document contains a C program that adds two matrices. It prompts the user to input the dimensions and elements of two matrices, computes their sum, and prints the resultant matrix. The program uses nested loops to handle the input and addition of matrix elements.

Uploaded by

Aneez Hassan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

add two matrices.

#include<stdio.h>
void main()
{
int m,n,i,j,a[3][3],b[3][3] ,c[3][3];
printf(“enter number of rows and columns\n”);
scanf(“%d %d”,&m,&n);
printf(“enter array a elements\n”);
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf(“%d”,&a[i][j]);
}
}
printf(“enter array b elements\n”);
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf(“%d”,&b[i][j]);
}
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
c[i][j]=a[i][j]+b[i][j];
}
}
printf(“resultant matrix c is \n”);
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf(“%d\t”,c[i][j]);
}
printf(“\n”);
}
}

You might also like