using System;
namespace Lab_Ex_9
{
class JaggedArrays
{
int[][] jagged = new int[3][];
public void ReadArrays()
{
Console.Write("\n Enter the size of First inner array: ");
jagged[0] = new int[int.Parse(Console.ReadLine())];
Console.WriteLine("\n Enter the elements of First inner array: ");
for (int i = 0; i < jagged[0].Length; i++)
jagged[0][i] = int.Parse(Console.ReadLine());
Console.Write("\n Enter the size of Second inner array: ");
jagged[1] = new int[int.Parse(Console.ReadLine())];
Console.WriteLine("\n Enter the elements of Second inner array: ");
for (int i = 0; i < jagged[1].Length; i++)
jagged[1][i] = int.Parse(Console.ReadLine());
Console.Write("\n Enter the size of Third inner array: ");
jagged[2] = new int[int.Parse(Console.ReadLine())];
Console.WriteLine("\n Enter the elements of Third inner array: ");
for (int i = 0; i < jagged[2].Length; i++)
jagged[2][i] = int.Parse(Console.ReadLine());
}
public void FindSum()
{
int sum = 0;
for (int i = 0; i < jagged[0].Length; i++)
sum = sum + jagged[0][i];
for (int i = 0; i < jagged[1].Length; i++)
sum = sum + jagged[1][i];
for (int i = 0; i < jagged[2].Length; i++)
sum = sum + jagged[2][i];
Console.WriteLine("\n\n\n Sum of all the three inner arrays is = {0}", sum);
}
public void PrintArrays()
{
Console.Write("\n\n Elements of First inner array: ");
for (int i = 0; i < jagged[0].Length; i++)
Console.Write(jagged[0][i] + "\t");
Console.Write("\n\n Elements of Second inner array: ");
for (int i = 0; i < jagged[1].Length; i++)
Console.Write(jagged[1][i] + "\t");
Console.Write("\n\n Elements of Third inner array: ");
for (int i = 0; i < jagged[2].Length; i++)
Console.Write(jagged[2][i] + "\t");
}
}
class ArrayTest
{
public static void Main()
{
JaggedArrays JA = new JaggedArrays();
JA.ReadArrays();
JA.PrintArrays();
JA.FindSum();
Console.ReadLine();
}
}
}
namespace Lab_Ex_9
{
class JaggedArrays
{
int[][] jagged = new int[3][];
public void ReadArrays()
{
Console.Write("\n Enter the size of First inner array: ");
jagged[0] = new int[int.Parse(Console.ReadLine())];
Console.WriteLine("\n Enter the elements of First inner array: ");
for (int i = 0; i < jagged[0].Length; i++)
jagged[0][i] = int.Parse(Console.ReadLine());
Console.Write("\n Enter the size of Second inner array: ");
jagged[1] = new int[int.Parse(Console.ReadLine())];
Console.WriteLine("\n Enter the elements of Second inner array: ");
for (int i = 0; i < jagged[1].Length; i++)
jagged[1][i] = int.Parse(Console.ReadLine());
Console.Write("\n Enter the size of Third inner array: ");
jagged[2] = new int[int.Parse(Console.ReadLine())];
Console.WriteLine("\n Enter the elements of Third inner array: ");
for (int i = 0; i < jagged[2].Length; i++)
jagged[2][i] = int.Parse(Console.ReadLine());
}
public void FindSum()
{
int sum = 0;
for (int i = 0; i < jagged[0].Length; i++)
sum = sum + jagged[0][i];
for (int i = 0; i < jagged[1].Length; i++)
sum = sum + jagged[1][i];
for (int i = 0; i < jagged[2].Length; i++)
sum = sum + jagged[2][i];
Console.WriteLine("\n\n\n Sum of all the three inner arrays is = {0}", sum);
}
public void PrintArrays()
{
Console.Write("\n\n Elements of First inner array: ");
for (int i = 0; i < jagged[0].Length; i++)
Console.Write(jagged[0][i] + "\t");
Console.Write("\n\n Elements of Second inner array: ");
for (int i = 0; i < jagged[1].Length; i++)
Console.Write(jagged[1][i] + "\t");
Console.Write("\n\n Elements of Third inner array: ");
for (int i = 0; i < jagged[2].Length; i++)
Console.Write(jagged[2][i] + "\t");
}
}
class ArrayTest
{
public static void Main()
{
JaggedArrays JA = new JaggedArrays();
JA.ReadArrays();
JA.PrintArrays();
JA.FindSum();
Console.ReadLine();
}
}
}