68 472
Assignments Done
98,7%
Successfully Done
In December 2018

Answer to Question #15901 in C# for leena

Question #15901
write a prg to create a jagged arrays as follows:
3 4 2 9 0
2 5
1 6 8

also write code to print the above jagged arrays in reverse order as follows:
0 9 2 4 3
5 2
8 6 1
Expert's answer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
&
class Program
{
& static void Main(string[] args)
& {
List<List<int>> MyArray = new List<List<int>>();

List<int> a = new List<int>();
a.Add(3); a.Add(4); a.Add(2); a.Add(9); a.Add(0);
MyArray.Add(a);
List<int> b = new List<int>();
b.Add(2); b.Add(5);
MyArray.Add(b);
List<int> c = new List<int>();
c.Add(8); c.Add(6); c.Add(1);
MyArray.Add(c);


for (int i = 0; i < MyArray.Count; i++)
{
for (int j = 0; j < MyArray[i].Count; j++)
{
& Console.WriteLine(MyArray[i][j]);
}
Console.WriteLine("\n");
}

for (int i = 0; i < MyArray.Count; i++)
MyArray[i].Reverse();

for (int i = 0; i < MyArray.Count; i++)
{
for (int j = 0; j < MyArray[i].Count; j++)
{
& Console.WriteLine(MyArray[i][j]);
}
Console.WriteLine("\n");
}
& }
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions