If I load your code into VS and run it:
int[,,] arr1 ={{{1,2},{4,3},},
{{8,6},{7,2 }},
{{11,9,},{91,24 }},};
Console.WriteLine("ENTER SET NO:");
int val = int.Parse(Console.ReadLine());
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 2; j++)
{
for (int k = 0; k < 2; k++)
{
if (val == arr1[i, j, k])
{
Console.WriteLine("value i:" + i);
Console.WriteLine("Value of j:" + j);
Console.WriteLine("Value of k:" + k);
}
}
}
}
(Reformatted for readability only)
I give it "3" and it correctly prints
ENTER SET NO:
3
value i:0
Value of j:1
Value of k:1
If I give it "2", it also correctly prints:
ENTER SET NO:
2
value i:0
Value of j:0
Value of k:1
value i:1
Value of j:1
Value of k:1
So what is the problem? Apart from it's a bit unreliable ...
I'd change it a little so that it's a bit more reliable:
int[,,] arr1 ={{{1, 2}, {4 , 3}},
{{8, 6}, {7 , 2}},
{{11,9}, {91,24}}};
Console.WriteLine("ENTER SET NO:");
int val = 3;
for (int i = 0; i < arr1.GetLength(0); i++)
{
for (int j = 0; j < arr1.GetLength(1); j++)
{
for (int k = 0; k < arr1.GetLength(2); k++)
{
if (val == arr1[i, j, k])
{
Console.WriteLine("value i:" + i);
Console.WriteLine("Value of j:" + j);
Console.WriteLine("Value of k:" + k);
}
}
}
}
As it's always a bad idea to use "magic numbers" in your code.