+ 1
Not getting the expected output.
I expected the output to be 2 but I'm getting a 3 instead. static int Find(int n) { int z = n - 1; int[] a = new int[4]; for(int i = 0; i < 4; i++) { a[i] = i + 2; } return a[z]; } static void Main(string[] args) { Console.WriteLine(Find(2)); } } }
1 Respuesta
+ 7
It's supposed to be 3.
Find (2)
=> So z = 2-1 = 1
Since a[i] = i+2,
inside the loop a[1] becomes 1+2 = 3