- Write a program to accept from user elements of two 2x3 matrices. Then add the two matrices and display the elements of resultant matrix.

View Answers

May 8, 2012 at 3:31 PM

**C sum of two matrices**

**The given code allow the user to enter the number of rows and columns of matrix. Accordingly, the code accepts the row and column values from the user and determine their sum.**

#include <stdio.h> #include <conio.h> void main() { int m, n, c, d, first[10][10], second[10][10], sum[10][10]; printf("Enter the number of rows and columns of matrix "); scanf("%d%d", &m, &n); printf("Enter the elements of first matrix\n"); for ( c = 0 ; c < m ; c++ ) for ( d = 0 ; d < n ; d++ ) scanf("%d", &first[c][d]); printf("Enter the elements of second matrix\n"); for ( c = 0 ; c < m ; c++ ) for ( d = 0 ; d < n ; d++ ) scanf("%d", &second[c][d]); for ( c = 0 ; c < m ; c++ ) for ( d = 0 ; d < n ; d++ ) sum[c][d] = first[c][d] + second[c][d]; printf("Sum of entered matrices:-\n"); for ( c = 0 ; c < m ; c++ ) { for ( d = 0 ; d < n ; d++ ) printf("%d\t", sum[c][d]); printf("\n"); } getch(); }

May 8, 2012 at 3:32 PM

If you another example then please go through the following link:

May 8, 2012 at 3:35 PM

**C++ Sum of matrix**

**The given code allow the user to enter the number of rows and columns of matrix. Accordingly, the code accepts the row and column values from the user and determine their sum.**

#include<iostream> #include<stdio.h> #include<conio.h> using namespace std; void main() { int m, n, c, d, first[10][10], second[10][10], sum[10][10]; cout << "Enter the number of rows and columns of matrix "; cin >> m >> n; cout << "Enter the elements of first matrix\n"; for ( c = 0 ; c < m ; c++ ) for ( d = 0 ; d < n ; d++ ) cin >> first[c][d]; cout << "Enter the elements of second matrix\n"; for ( c = 0 ; c < m ;c++ ) for ( d = 0 ; d < n ; d++ ) cin >> second[c][d]; for ( c = 0 ; c < m ; c++ ) for ( d = 0 ; d < n ; d++ ) sum[c][d] = first[c][d] + second[c][d]; cout << "Sum of entered matrices:-\n"; for ( c = 0 ; c < m ; c++ ) { for ( d = 0 ; d < n ; d++ ) cout << sum[c][d] << "\t"; cout << endl; } getch(); }

Ads

Related Tutorials/Questions & Answers:

Write a C language program to read two matrices and multiply them? Write a C language program to read two matrices and multiply them? Here is an example of multiplying two matrices using C language. #include <

with out using scanner mul two matrices write a java program to multiply two matrices and print there result. note: don't use the scanner...]; System.out.println("Enter elements for matrix A : "); for (int i=0 ; i

Advertisements

multiplication of two matrices. In java this is a simple program to multiply two matrices... two-dimensional array. Here we are going to develop a Java code for matrices multiplication, while multiplying two matrices the number of column in first

and then accept the matrix elements as array elements. We have declared two... the subtraction of two matrices. Not only, addition and multiplication, you can... between two matrices of any order. In the given program, firstly we have allowed

question for c++ write Program to swap between two numbers if first number is greater than second number and total of two numbers greater than 10

and then accept the matrix elements as array elements. We have declared two... to multiply two matrices. Like mathematical operations of two numbers, you can... the multiplication of two matrices of any order. In the given program, firstly we have

the sum of two matrices. You may have solved many Matrix Operations in Mathematics... to show in matrices and then accept the matrix elements as array elements. We have declared two 2-dimensional array of integer type to store the matrix elements

C# question Write a program in C# to create 3*4 matrix and show the sum of diagonal values

C# question Write a program in C# to create 3*4 matrix and show the sum of diagonal values

C/C++/JAVA Question on function "Write a function to find out common alphabets between two arrays. Length of array is not fixed and may contain other data type also.Ã¢â?¬Â? Question can be solved in C,C++ or JAVA

Create a Solution by name Bank with Classes Account.cs, SavingsAccount.cs and savingsTest.cs to Demonstrate Abstract Classes in C# 1st question... and savingsTest.cs to Demonstrate Abstract Classes in C

question for c++ write Program to swap between two numbers if first number is greater than second number and total of two numbers greater than 10 Ã?Â¨Ã?Â±Ã?â? Ã?Â§Ã?â?¦Ã?Â¬ Ã?â??Ã?â?¦Ã?Â¨Ã?Â§Ã?Â¯Ã?â??Ã?Â© Ã?Â¨Ã

c question How to convert decimal numbers into binary digits without using pow function in c language

Sum of two Matrix In this section, we are going to calculate the sum of two matrix... to this. In this program we are going to calculate the sum of two matrix. To make this program

turbo C Question 6. Explain call by value and call by reference with easy examples

turbo C Question 4. Possible to print the following (Using for Loops): 1. * ** 2.* * ** * * * * specify the format properly

turbo C Question 4. Possible to print the following (Using for Loops): 1. * ** 2.* * ** * * * * specify the format properly

for multiplying two matrix to each other. Here providing you Java source code... program that will multiply two matrix. Two dimensional array represents the matrix. Now, make this program, you have to declare two multidimensional array

Write a question to display the follwing Write a Java program to display a pattern? String str = ""; int count = 4; for( int i=9,j...++; } System.out.print(str); class Display { public void

of these two classes has a member function displayArea()to display the area...C++ Triangle and Rectangle - calculate area of Triangle and rectangle using data members from base class 2.create class. Shape accepts two values

Dividing of two Matrix in Java ...;Here you will learn how to use two matrix array for developing Java program. The java two dimensional array program is operate the two matrix. Now we

question about mixing two strings using java script we need to ask two strig and combine them like.. str1= helo str2= worl combined string= hweolrol

turbo C Question 5. is it possible to print "", 1st line (5 times),2nd line *(4 times),3rd line *(3 times),4th line *(2 times) & 5th line *(1 times) with Align Right. and also reverse order as 1,2,3,4,5 (but right aline

concatenation of Two bytes in C Hi, I need to concatenate two bytes array in C.How to do that. bytes[0] = (n >> 24) & 0xFF; bytes[1] = (n >> 16) & 0xFF; bytes[2] = (n >> 8) & 0xFF; bytes[3] = n &

that compare two array lists and display the common elements from both of them...How to Display Duplicate elements from more than one List in java? How to Display Duplicate elements from more than one List in java? //I mean

will write a simple program, which will multiply two matrix. A Two dimensional array... to multiply two matrix To initiate with the program, you have to declare two... matrix System.out.println("Enter the elements of first matrix

Display tow dimensional array by matrix form using one for loop in java Display tow dimensional array by matrix form using one for loop in java

Need coding help - two dimensional matrix and it returns back a boolean. I need to write a code method that accepts a two dimensional integer arrays as the argument and returns true if the array or matrix is left or right