write a c program to add two matrices
Answers
Answer:
what is mean by program to add two matrices write answer hard ok
Answer:
How to write a C Program to Add Two Matrices?. Or, How to write a C program to add two Multi-Dimensional Arrays with example.
Explanation:
This program for matrix addition in c allows the user to enter the number of rows and columns of two Matrices. Next, we are going to add those two matrices using For Loop.
/* C Program to Add Two Matrices */
#include<stdio.h>
int main()
{
int i, j, rows, columns, a[10][10], b[10][10];
int Addition[10][10];
printf("\n Please Enter Number of rows and columns : ");
scanf("%d %d", &i, &j);
printf("\n Please Enter the First Matrix Elements\n");
for(rows = 0; rows < i; rows++)
{
for(columns = 0; columns < j; columns++)
{
scanf("%d", &a[rows][columns]);
}
}
printf("\n Please Enter the Second Matrix Elements\n");
for(rows = 0; rows < i; rows++)
{
for(columns = 0; columns < j; columns++)
{
scanf("%d", &b[rows][columns]);
}
}
for(rows = 0; rows < i; rows++)
{
for(columns = 0; columns < j; columns++)
{
Addition[rows][columns] = a[rows][columns] + b[rows][columns];
}
}
printf("\n The Sum of Two Matrix a and b = a + b \n");
for(rows = 0; rows < i; rows++)
{
for(columns = 0; columns < j; columns++)
{
printf("%d \t ", Addition[rows][columns]);
}
printf("\n");
}
return 0;
}