ExamVeda
Login
Home
Miscellaneous in C Sharp
?

What will be the output of the following C# code snippet?
class UnsafeCode
{
    unsafe static void Main()
    {
        int* ptrs = stackalloc int[3];
        ptrs[0] = 1;
        ptrs[1] = 2;
        ptrs[2] = 3;
        for (int i = 2; i >= 0; --i)
        {
            ptrs[i] = ptrs[i]* 3;
            ptrs[i] = ptrs[i] + 4;
            Console.WriteLine(ptrs[i]);
        }
        Console.ReadLine();
    }
}

Answer & Solution
Correct Answer: Option B
Let's discuss the solution. Join the discussion
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.