using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int[,] a = new int[5, 5];
int[,] b = new int[5, 5];
int i,j, row,coln;
Console.Write("Enter the row and column");
row = int.Parse(Console.ReadLine());
coln = int.Parse(Console.ReadLine());
Console.Write("Enter the first matrix");
for (i = 0; i < row; i++)
{
for (j = 0; j < coln; j++)
{
a[i, j] = int.Parse(Console.ReadLine());
}
}
Console.Write("Enter the second matrix");
for (i = 0; i < row; i++)
{
for (j = 0; j < coln; j++)
{
b[i, j] = int.Parse(Console.ReadLine());
}
}
Console.Write("The sum of the matrix is:");
for (i = 0; i < row; i++)
{
Console.Write("\n");
for (j = 0; j < coln; j++)
{
a[i, j] = a[i, j] + b[i, j];
Console.Write("\t" + a[i, j]);
}
}
Console.ReadKey();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int[,] a = new int[5, 5];
int[,] b = new int[5, 5];
int i,j, row,coln;
Console.Write("Enter the row and column");
row = int.Parse(Console.ReadLine());
coln = int.Parse(Console.ReadLine());
Console.Write("Enter the first matrix");
for (i = 0; i < row; i++)
{
for (j = 0; j < coln; j++)
{
a[i, j] = int.Parse(Console.ReadLine());
}
}
Console.Write("Enter the second matrix");
for (i = 0; i < row; i++)
{
for (j = 0; j < coln; j++)
{
b[i, j] = int.Parse(Console.ReadLine());
}
}
Console.Write("The sum of the matrix is:");
for (i = 0; i < row; i++)
{
Console.Write("\n");
for (j = 0; j < coln; j++)
{
a[i, j] = a[i, j] + b[i, j];
Console.Write("\t" + a[i, j]);
}
}
Console.ReadKey();
}
}
}
/*Do leave a comment if you find this useful*/
No comments:
Post a Comment