# C# Program to Find the Sum of Each Row of the Matrix

## C# Program to Find the Sum of Each Row of the Matrix

``````//C# program to find the sum of each row of the matrix.

using System;

class MatrixDemo
{
public static void Main(string[] args)
{
int i   = 0;
int j   = 0;

int sum = 0;
int row = 2;
int col = 2;

int[,] Matrix = new int[row, col];

Console.Write("Enter the elements of matrix: ");
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
}
}

Console.WriteLine("\nMatrix: ");
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
Console.Write(Matrix[i, j] + "\t");
}
Console.WriteLine();
}

for (i = 0; i < row; i++)
{
sum = 0;
for (j = 0; j < col; j++)
{
sum += Matrix[i, j];
}
Console.WriteLine("Sum of row[{0}]: {1}", (i + 1), sum);
}
}
}
``````
``````Enter the elements of matrix: 1
2
3
4

Matrix:
1       2
3       4
Sum of row[1]: 3
Sum of row[2]: 7
Press any key to continue . . .
``````

## Final Words

C# Program to Find the Sum of Each Row of the Matrix We hope this article solves all your doubts. If in doubt let me know.

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Deekshi. Here, I post about programming to help developers.

Share on: