/*4.Develop a C#.NET console application to find sum of all elements present in jagged array
of 3 inner arrays.*/
using System;
class MainClass
{
public static void Main (string[] args)
{
int[][] accounts = new int[3][];
accounts[0] = new int[] { 10, 20, 30 };
accounts[1] = new int[] { 20, 30, 40 };
accounts[2] = new int[] { 30, 40, 50 };
var maxAccountSum = Int32.MinValue; // To account for if the accounts have negative balances? Like they were all overdrafted or something.
for (var i = 0; i < accounts.Length; i++)
{
var accountSum = 0;
for (var j = 0; j < accounts[i].Length; j++)
{
accountSum += accounts[i][j];
}
maxAccountSum = Math.Max (maxAccountSum, accountSum);
Console.WriteLine ("sum of array {0}.= {1}",i, accountSum);
}
Console.WriteLine ("The highest sum in an account is {0}.", maxAccountSum);
}
}