What Will Be The Output Of The Following C Codep Pre Langcsharp #178
What will be the output of the following C# code?</p> <pre><code class="language-csharp" line="1"> static void Main(string[] args) { int []a = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; func(ref a); Console.ReadLine(); } static void func(ref int[] x) { Console.WriteLine(" numbers are:"); for (int i = 0; i < x.Length; i++) { if (x[i] % 2 == 0) { x[i] = x[i] + 1; Console.WriteLine(x[i]); } } } </code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs108 CSharp. It can also be found in gs gs108 Classes - Reference Variables and Assignment - Quiz No.1.
What will be the output of the following C# code?
static void Main(string[] args) { int []a = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; func(ref a); Console.ReadLine(); } static void func(ref int[] x) { Console.WriteLine(" numbers are:"); for (int i = 0; i < x.Length; i++) { if (x[i] % 2 == 0) { x[i] = x[i] + 1; Console.WriteLine(x[i]); } } }
numbers are : 2 4 6 8 10
numbers are : 3 5 7 9 11
numbers are : 2 3 4 5 6
none of the mentioned