Consider the following code. int fun() { if(isEmpty()) { return -10; } else {…
2024
Consider the following code.
int fun()
{
if(isEmpty())
{
return -10;
}
else
{
int n;
n= q[front];
front++;
return n;
}
}
Which operation does the above code perform?
- A.
Enqueue
- B.
Dequeue
- C.
Return the front element
- D.
Both b and c
Attempted by 332 students.
Show answer & explanation
Correct answer: D
Answer: d
Explanation: The answer is d because two operations are performed in the above code. The first one is returning the value of the front with the help of the statement n=q[front], and the second operation is dequeue (deleting an element) by using the statement front++.