0 votes
98 views
in C programming by (98.9k points)
edited
Write a program to add two matrices m x n

1 Answer

0 votes
by (98.9k points)
selected by
 
Best answer
#include<stdio.h>
 
int main()
{
 	int i, j, rows, columns, a[10][10], b[10][10];
 	int arr[10][10];
  
 	printf("\n Please Enter Number of rows and columns  :  ");
 	scanf("%d %d", &i, &j);
 
 	printf("\n Please Enter the First 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 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++)
    	{
      		arr[rows][columns] = a[rows][columns] + b[rows][columns];    
   	 	}
  	}
 
 	printf("\n The Sum of Two a and b = a + b \n");
 	for(rows = 0; rows < i; rows++)
  	{
   		for(columns = 0; columns < j; columns++)
    	{
      		printf("%d \t ", arr[rows][columns]);
    	}
    	printf("\n");
  	}
 	return 0;
}

Related questions

0 votes
1 answer 191 views
asked Apr 23, 2022 in C programming by Doubtly (98.9k points)
0 votes
1 answer 150 views
asked Jul 20, 2022 in C programming by Doubtly (98.9k points)
0 votes
1 answer 121 views
asked Jul 20, 2022 in C programming by Doubtly (98.9k points)
0 votes
1 answer 196 views

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

554 users

...