Complete the code to add an element to the queue.
Queue<int> queue = new Queue<int>(); queue.[1](10);
Push which is for stacks, not queues.Add which is not a method of Queue.The Enqueue method adds an element to the end of the queue, following FIFO.
Complete the code to remove the first element from the queue.
int first = queue.[1]();Pop which is for stacks, not queues.Remove which is not a method of Queue.The Dequeue method removes and returns the element at the front of the queue, following FIFO.
Fix the error in the code to check the first element without removing it.
int peek = queue.[1]();Dequeue which removes the element.Top which is not a Queue method.The Peek method returns the first element without removing it, preserving the queue.
Fill both blanks to create a queue and add two elements.
Queue<string> queue = new [1]<string>(); queue.[2]("apple");
Stack instead of Queue.Push which is for stacks.We create a Queue and add elements using Enqueue to follow FIFO.
Fill both blanks to remove an element and check the next element in the queue.
int removed = queue.[1](); int next = queue.[2](); Console.WriteLine(removed + " -> " + next);
Pop to remove from queue.Top which is not a queue method.Dequeue removes the first element, Peek shows the next element without removing it.
