using System;
namespace ClassRoomSamples
{
class Demo07ThreeDimArray
{
static void Main(string[] anyName)
{
//2 Batches,3 Students,2 Subjects
int[,,] a = new int[2, 3, 2];
int bat, sd, sub;
for (bat = 0; bat < 2; bat++)
{
Console.WriteLine("Details of Batch{0}", bat+1);
for (sd = 0; sd < 2; sd++)
{
for (sub = 0; sub < 2; sub++)
{
Console.WriteLine("Enter mark{0} of student{1} of batch{2}", sub+1, sd+1, bat+1);
a[bat, sd, sub] = int.Parse(Console.ReadLine());
}
}
}
Console.WriteLine("Result Processed....");
for (bat = 0; bat < 2; bat++)
{
Console.WriteLine("Batch{0}", bat+1);
for (sd = 0; sd < 2; sd++)
{
Console.Write("Student{0}\t", sd+1);
for (sub = 0; sub < 2; sub++)
{
Console.Write("{0}\t", a[bat, sd, sub]);
}
}
}
Console.ReadKey();
}
}
}
Details of Batch1
Enter mark1 of student1 of batch1
80
Enter mark2 of student1 of batch1
81
Enter mark1 of student2 of batch1
90
Enter mark2 of student2 of batch1
91
Details of Batch2
Enter mark1 of student1 of batch2
70
Enter mark2 of student1 of batch2
70
Enter mark1 of student2 of batch2
60
Enter mark2 of student2 of batch2
61
Result Processed....
Batch1
Student1 80 81
Student2 90 91
Batch2
Student1 70 70
Student2 60 61
No comments:
Post a Comment