Question
class UnsafeCode
{
unsafe static void Main()
{
int[] nums = new int[10];
Console.WriteLine("Index pointer like array.");
fixed (int* p = nums)
{
for (int i = 0 ;i <10 ;i++)
p[i] = i;
for (int i = 10 ;i >0 ;i--)
Console.WriteLine("p[{0}]: {1} ", i, p[i]);
Console.ReadLine();
}
}
}
a.
p[10] :0, p[9] :9, p[8] :8…..p[1]:1
b.
p[10] : 1, p[9] :2, p[8] :3…..p[1] :0
c.
p[1] : 1, p[2] :2, p[3] :3…..p[10] :0
d.
Compile time error
Posted under C# programming
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 given code snippet?
Similar Questions
Discover Related MCQs
Q. What will be the declaration of the variable ptr as the pointer to array of 6 floats?
View solution
Q. A structure pointer points to __________
View solution
Q. Among the given pointers which of following cannot be incremented?
View solution
Q. Consider an integer pointer *a.
++*a will increment ___________ while *a++ will increment __________
View solution
Q. How many values can be returned from a function simultaneously using pointers?
View solution
Q. Among the given pointer which of following cannot be incremented?
View solution
Q. Which among the following is referred as an array of pointers?
View solution
Q. Which of the following job is done by the instruction ++*p for an integer pointer p?
View solution
Q. After incrementing a float pointer ptr by 1 it would be incremented by __________
View solution
Q. What is the size of a char pointer?
View solution
Q. Choose the correct statement among the given statements?
View solution
Q. Which among the given operators is referred to as ‘address of’ operator?
View solution
Q. Pointer variable is used to hold the _________ of the variable.
View solution
Q. Select the type argument of open constructed type?
View solution
Q. Which of these is an correct way of defining generic method?
View solution
Q. Why are generics used?
View solution
Q. Which of these methods gives the full URL of an URL object?
View solution
Q. Which of these classes is used to create servers that listen to either local or remote client programs?
View solution
Q. Choose the exceptions generated by the GetResponseStream() method defined by WebRequest:
View solution
Q. Which of these classes is used for operating on the request from the client to the server?
View solution
Suggested Topics
Are you eager to expand your knowledge beyond C# programming? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!