Assume that IntQueue is an integer queue. void fun(int n) { IntQueue q = new Int
ID: 3556161 • Letter: A
Question
Assume that IntQueue is an integer queue.
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);
ptint(a);
}
}
What does the function fun do?
a) Prints first n Fibonacci numbers
b) Prints numbers from 0 to n-1
c) Prints numbers from n-1 to 0
d) Prints first n Fibonacci numbers in reverse order
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);
ptint(a);
}
}
What does the function fun do?
a) Prints first n Fibonacci numbers
b) Prints numbers from 0 to n-1
c) Prints numbers from n-1 to 0
d) Prints first n Fibonacci numbers in reverse order
Explanation / Answer
Ans.
a) Prints first n Fibonacci numbers
0,1,1,2,3...
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.