Consider the following pseudo code. Assume that IntQueue is an integer queue.…

PYQ Hexaware Hiring Assessment 2023

Consider the following pseudo code. Assume that IntQueue is an integer queue. What does the function fun do?

void fun(int n)
{
    IntQueue q = new IntQueue();
    q.enqueue(0);
    q.enqueue(1);
    for (int i = 0; i < n; i++)
    {
        int a = q.dequeue();
        int b = q.dequeue();
        q.enqueue(b);
        q.enqueue(a + b);
        print(a);
    }
}
  1. A.

    Prints numbers from 0 to n-1

  2. B.

    Prints numbers from n-1 to 0

  3. C.

    Prints first n Fibonacci numbers

  4. D.

    Prints first n Fibonacci numbers in reverse order.

Attempted by 93 students.

Sign up free to check your answer

Sign up free

Explore the full course: Cdac C Cat Complete Preparation

Loading lesson…