C# Program To Add Two Matrices - Simple2Code
C# Program To Add Two Matrices - Simple2Code
C# Programs
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
Java Tutorial
catch (System.Exception ex)
{ javascript
Console.WriteLine("Invalid input !!");
Uncategorised
}
}
}
return matrix;
}
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;
}
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());
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