-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path04 ● 2D array.cs
32 lines (31 loc) · 1018 Bytes
/
04 ● 2D array.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
namespace DD_ARRAY
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter the number of rows ");
int rows = int.Parse(Console.ReadLine());
Console.WriteLine("Enter the number of columns ");
int columns = int.Parse(Console.ReadLine());
int[,] Arr = new int[rows, columns];
for(int i = 0; i < Arr.GetLength(0); i++)//Read input
{
for(int j = 0; j < Arr.GetLength(1);j++)
{
Console.WriteLine("Enter {0},{1} Element " , i , j);
Arr[i, j] = int.Parse(Console.ReadLine());
}
}
for(int i = 0; i < Arr.GetLength(0); i++)//Print output
{
for(int j = 0; j < Arr.GetLength(1);j++)
{
Console.Write(Arr[i,j] + " ");
}
Console.WriteLine();
}
}
}
}