using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ArrayElementsAddition
{
class Program
{
static void Main(string[] args)
{
int[,] a = new int[5, 2];
int i, j, sum = 0;
for (i = 0; i < 5; i++)
{
for (j = 0; j < 2; j++)
{
a[i, j] = Convert.ToInt32(Console.ReadLine());
}
}
Console.WriteLine("Array Elements");
for (i = 0; i < 5; i++)
{
for (j = 0; j < 2; j++)
{
Console.Write(" " + a[i, j]);
}
Console.WriteLine();
}
for (i = 0; i < 5; i++)
{
for (j = 0; j < 2; j++)
{
sum = sum + a[i, j];
}
}
Console.WriteLine("Sum: " + sum);
Console.ReadLine();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ArrayElementsAddition
{
class Program
{
static void Main(string[] args)
{
int[,] a = new int[5, 2];
int i, j, sum = 0;
for (i = 0; i < 5; i++)
{
for (j = 0; j < 2; j++)
{
a[i, j] = Convert.ToInt32(Console.ReadLine());
}
}
Console.WriteLine("Array Elements");
for (i = 0; i < 5; i++)
{
for (j = 0; j < 2; j++)
{
Console.Write(" " + a[i, j]);
}
Console.WriteLine();
}
for (i = 0; i < 5; i++)
{
for (j = 0; j < 2; j++)
{
sum = sum + a[i, j];
}
}
Console.WriteLine("Sum: " + sum);
Console.ReadLine();
}
}
}
Output:
No comments:
Post a Comment