Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Register
Login
.NET
ADO.NET
Android
ASP.NET
C#
Databases & DBA
Design Patterns & Practices
iOS
Java
OOP/OOD
SharePoint
Software Testing
Web Development
WPF
View All
1
Reply
write a c# program add two matrix with input number ?
rahul jaiswal
12y
4.9k
0
Reply
Submit
using System;
using System.Collections.Generic;
using System.Text;
namespace AddMatrixUser
{
class Program
{
static void Main(string[] args)
{
int[,] a = new int[2, 2];
//int number = 0;
int[,] b = new int[2, 2];
Console.WriteLine("Enter ther Element");
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 2; j++)
{
a[i,j] = Convert.ToInt32(Console.ReadLine());
}
}
Console.WriteLine("Enter the second Matrix");
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 2; j++)
{
b[i, j] = Convert.ToInt32(Console.ReadLine());
}
}
Console.WriteLine("\t"+"First Matrix");
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 2; j++)
{
Console.Write("\t"+a[i,j]);
}
Console.WriteLine("");
}
Console.WriteLine("\t"+"Second Matrix");
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 2; j++)
{
Console.Write("\t"+b[i, j]);
}
Console.WriteLine(" ");
}
Console.WriteLine("\t"+"Add Matrix");
for (int k = 0; k < 2; k++)
{
for (int l = 0; l < 2; l++)
{
Console.Write("\t"+(a[k,l]+b[k,l]));
}
Console.WriteLine(" ");
}
Console.WriteLine("\t" + "Its user input add two matrix " + "\n" + "rahul kumar jaiswal");
Console.ReadLine();
}
}
}
rahul jaiswal
12y
0
Message