adplus-dvertising
frame-decoration

Question

What will be the output of the 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();
    }
}

a.

20, 10, 7

b.

13, 10, 7

c.

6, 9, 3

d.

Compile time error

Posted under C# programming

Answer: (b).13, 10, 7

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What will be the output of the code snippet?

Similar Questions

Discover Related MCQs

Q. Consider an integer pointer *a.
++*a will increment ___________ while *a++ will increment __________

Q. How many values can be returned from a function simultaneously using pointers?

Q. Among the given pointer which of following cannot be incremented?

Q. Which among the following is referred as an array of pointers?

Q. Which of the following job is done by the instruction ++*p for an integer pointer p?

Q. After incrementing a float pointer ptr by 1 it would be incremented by __________

Q. What is the size of a char pointer?

Q. Choose the correct statement among the given statements?

Q. Which among the given operators is referred to as ‘address of’ operator?

Q. Pointer variable is used to hold the _________ of the variable.

Q. Select the type argument of open constructed type?

Q. Which of these is an correct way of defining generic method?

Q. Why are generics used?

Q. Which of these methods gives the full URL of an URL object?

Q. Which of these classes is used to create servers that listen to either local or remote client programs?

Q. Choose the exceptions generated by the GetResponseStream() method defined by WebRequest:

Q. Which of these classes is used for operating on the request from the client to the server?

Q. Select the properties related to the network errors generated by WebException:

Q. Choose the exceptions generated by the GetReponse() method defined by WebRequest:

Q. Choose the exceptions generated by the Create() method defined by WebRequest: