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?

Answer: D. Both b and cAnswer: 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…

  1. A.

    Enqueue

  2. B.

    Dequeue

  3. C.

    Return the front element

  4. D.

    Both b and c

Attempted by 438 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++.

Explore the full course: Cognizant Preparation

Loading lesson…