Examveda

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]);
        }
    }
}

A. numbers are : 2 4 6 8 10

B. numbers are : 3 5 7 9 11

C. numbers are : 2 3 4 5 6

D. none of the mentioned

Answer: Option B


Join The Discussion

Related Questions on Classes and Objects in C Sharp