You are on page 1of 1

using System;

using System.Collections.Generic;
using System.Text;
namespace jaggedarray
{
class Program
{
static void Main(string[] args)
{
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.DarkGreen;
int countRow = 1;
Console.WriteLine("Enter No. Of Rows :");
int nor = Convert.ToInt32(Console.ReadLine());
int[][] jArray = new int[nor][];
for (int i = 0; i < nor; i++)
{
Console.WriteLine("Enter No.of Coulumns for " + countRow + " Row
:");
int elemt = Convert.ToInt32(Console.ReadLine());
jArray[i] = new int[elemt];
countRow++;
}
Console.WriteLine("Enter Elements of Jagged Array :");
int countCol = 1;
for (int row = 0; row < jArray.Length; row++)
{
Console.WriteLine("Enter Elements For : " + countCol + " Row :"
);
for (int col = 0; col < jArray[row].Length; col++)
{
// jArray[row][col] = int.Parse(Console.ReadLine());
jArray[row][col] = Convert.ToInt32(Console.ReadLine());
}
countCol++;
}
Console.WriteLine("Your Jagged Array :");
for (int r = 0; r < jArray.Length; r++)
{
for (int c = 0; c < jArray[r].Length; c++)
{
Console.Write(jArray[r][c]);
Console.Write("\0");
}
Console.WriteLine("");
} Console.ReadKey();
}
}
}

You might also like