Thursday 30 August 2012

Array program in C sharp | C# array programming

ARRAY  program in  C sharp | source code

namespace array_2d
{
class Program
{
static void Main(string[] args)
{
int[,] mat = new int[3, 3];
int i, j,sum=0;

Console.WriteLine("Enter 9 elements:");
for (i = 0; i < 3; i++)
{
for (j = 0; j < 3; j++)
{
Console.WriteLine("Enter element:");
mat[i, j] = Convert.ToInt16(Console.ReadLine());
}
}

Console.WriteLine("\nThe array entered is:\n");
for (i = 0; i < 3; i++)
{
for (j = 0; j < 3; j++)
Console.Write(mat[i, j]+"\t");

Console.WriteLine("\n");
}

Console.WriteLine("The sum of array elments is:");
for (i = 0; i < 3; i++)
{
for (j = 0; j < 3; j++)
sum=sum + mat[i, j];
}
Console.WriteLine(sum);

Console.ReadLine();
}
}
}
Share This
Previous Post
Next Post

FYJC XI standard online admisson Process and declaraton of Merit list . Cut off List For prevous year also . 10 Th Results onlne declaraton Maharashtra Region .

0 comments: