Azim Ajmeri
C++ question - add the two matrices and display the elements of resultant matrix.
3 Answer(s)      4 years and 11 months ago
Posted in : Hibernate
1. Write a program to accept from user elements of two 2x3 matrices. Then add the two matrices and display the elements of resultant matrix.

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

C Sum of two matrices

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();
}
```

Write a C language program to read two matrices and multiply them?
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 <
C Addition of two matrices In this section, we are going to calculate the sum of  two 2 X 2 matrices containing rows and columns. For this , we need... to input values for two matrices. To make the matrix of 2 X 2, we are using
with out using scanner mul two matrices
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
Matrix multiplication in java
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
Matrix multiplication
Matrix multiplication  program to read the elements of the given two matrices of order n*n and to perform the matrix multiplication
Java Matrix Subtraction Example
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
Java Matrix Multiplication Example
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
C# question  Write a program in C# to create 3*4 matrix and show the sum of diagonal values
C# question
C# question  Write a program in C# to create 3*4 matrix and show the sum of diagonal values
question for 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
Multiplication of two Matrix
Multiplication of Two Matrix   ... that teaches you the method to multiply two matrix. We are going to make a simple program that will multiply two matrix. Now to make this program run, you need
Sum of two Matrix
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
Multiplication of two Matrix
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
C# question
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
Dividing of two Matrix in Java
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 for 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/C++/JAVA Question on function
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
C# question
C# question  Explain enumeration base types in C
C# question
C# question  In C#, string is a class or primitive type. Explain
Sum of diagonal of Matrix in C
C Sum of diagonal of Matrix In this section, you will learn how to determine the sum of both the diagonal of 3X3 matrix. For this, we have declared an array of integers and using the for loops, we have determined the sum of both
c question
c question  How to convert decimal numbers into binary digits without using pow function in c language
C# question
C# question  How can we call method pass by reference in C
want to display the follwing matrix format - Java Beginners
want to display the follwing matrix format  Hi frends, Actually i was working on the following matrix format........I neeed to use arraylist... gives 3 then he should get 3*3 matrix with folllowing data, and when user gives 4
Display Common Elements from two ArrayLists in Java
Display Common Elements from two ArrayLists in Java In this section, we are going to compare two array lists and display the common elements from both of them. To show the common elements from the two list, we have created two array
Display Different Elements from two ArrayLists in Java
Display Different Elements from two ArrayLists Java In this section, we are going to compare two array lists and display the different elements from both of them. To show the different elements from the two list, we have created two
Need coding help - two dimensional matrix and it returns back a boolean.
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
Matrix Multiplication in Java
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
C Program for Addtion of 2*2 Diagnol Matrix - Development process
C Program for Addtion of 2*2 Diagnol Matrix   Hello Sir, I want C Program to Do Addtion of Diagnol Matrix in C language. Plz Give Me   Hi...],b[2][2],c[2][2],i,j; clrscr(); printf("Enter the First matrix:\n"); for(i=0
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  Display tow dimensional array by matrix form using one for loop in java
Java, matrix
]; int[][] C = new int[2][2]; System.out.println("Enter elements for matrix...++){ A[i][j] = input.nextInt(); } System.out.println("Enter elements for matrix B... of 2 matrices*"); for(int i=0;i<2;i++){ for(int j=0;j<2;j++){ C[i][j
Tutorials