Home
Download Java App:C
Android C++ C# Apps Blog About
Follow Us: Us
C# Tutorial
C# Programs
C# Program to Add Two SEARCH …
Matrices 2 min read
22 March 2021
In this article, you will dd two matrices in C#. For matrix MORE TOPICS
addition, we require two matrices and both the matrices must Find the output ab, cd, ef, g
be a square matrix. for the input a,b,c,d,e,f,g in
Javascript and Python
1 February 2023
Explanation:
String Pattern Programs in
We first take the user input for a number of rows and the
C
number of columns. Then passing rows and columns, we take
29 July 2022
input for two matrices A & B. Then those matrices are added
Java Program to Find pair
as shown in the following program. And lastly, the result matrix of Integers in Array whose
is displayed. sum is given Number
25 July 2022
Program to Print Diamond
Alphabet Patterns in C
22 July 2022
C# Program for Matrix Addition Half Diamond Pattern in C
using Alphabets
Source Code: The program shows the addition of matrices in 22 July 2022
C# using classes. Half Pyramid of Alphabets
in C
using System; 20 July 2022
Inverted Half Pyramid
class MatrixAddition
Pattern of Alphabets in C
{
19 July 2022
int n, m;
//Input of First Matrix
public int[, ] GetMatrixA(int n, int m)
Home
{ Java C C++ C# Apps Blog About Us
CATEGORIES
this.n = n;
C Programs
this.m = m; C# Tutorial
C Tutorial
int[, ] matrix = new int[n, m];
C# Programs
Console.WriteLine("Enter A {0} x {1} matrix", n, m); computer fundamentals
for (int i = 0; i < n; i++)
CPlusPlus Programs
{
for (int j = 0; j < m; j++) CPlusPlus Tutorial
{
CSharp Programs
var input = Console.ReadLine();
try CSharp Tutorial
{
HTML
matrix[i, j] = int.Parse(input);
} Java Programs
Java Tutorial
catch (System.Exception ex)
{ javascript
Console.WriteLine("Invalid input !!");
Uncategorised
}
}
}
return matrix;
}
//Input of Second Matrix
public int[, ] GetMatrixB(int n, int m)
{
this.n = n;
this.m = m;
int[, ] matrix = new int[n, m];
Console.WriteLine("Enter B {0} x {1} matrix", n, m);
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
var input = Console.ReadLine();
try
{
matrix[i, j] = int.Parse(input);
}
catch (System.Exception ex)
{
Console.WriteLine("Invalid input !!");
}
}
}
return matrix;
}
Home
//Addition Java C
Matrices
of two C++ C# Apps Blog About Us
public int[, ] AddMatrix(int[, ] a, int[, ] b)
{ C# Tutorial
int[, ] result = new int[n, m];
for (int i = 0; i < n; i++)
C# Programs
{
for (int j = 0; j < m; j++)
{
result[i, j] = a[i, j] + b[i, j];
}
}
return result;
}
//Displaying the result
public void DisplayMatrix(int[, ] matrix)
{
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
Console.Write(matrix[i, j] + "\t");
}
Console.WriteLine("");
}
}
}
class Program
{
static void Main(string[] s)
{
MatrixAddition matrix = new MatrixAddition();
int m, n;
Console.WriteLine("Enter Number Of Rows And Columns(must be s
m = Convert.ToInt16(Console.ReadLine());
n = Convert.ToInt16(Console.ReadLine());
int[, ] a = matrix.GetMatrixA(m, n);
int[, ] b = matrix.GetMatrixB(m, n);
Console.WriteLine("Result of A + B:");
matrix.DisplayMatrix(matrix.AddMatrix(a, b));
}
}
Output:
Home Java C C++ C# Apps Blog About Us
C# Tutorial
C# Programs
MORE
Find the String Java
output ab, Pattern Program to
cd, ef, g for Programs in Find pair of
the input C Integers in
a,b,c,d,e,f,g In this tutorial, we Array whose
in Javascript will write various sum is given
and Python C pattern Number
In this tutorial, we programs for In this tutorial, we
will write a String. Before will write a
program to find a that, you may go program to find a
pairs of elements through the pair of elements
from an array following topics in from an array
such that for the C. for loop … whose sum
input [a,b,c,d,e,f,g] equals a given
Read More
we will … number in java …
Read More Read More