Time Left - 15:00 mins

# GATE 2022 : Data Structure and Programming Quiz- 5

Attempt now to get your rank among 272 students!

Question 1

What is the sum of outputs printed by running the following program?
int main ( )
{
int i ;
for (i = 3; i < = 6; i++)
printf(“%d”, f1(i));
}
int f1 (int n)
{
if (n < 2) return n;
else return (f1(n –1) + f2(n – 2));
}
int f2 (int n)
{
if (n < = 1) return n;
else return (2 f1 (n – 2) + 1);
}

Question 2

Consider the following function.
void f (int n)
{
if (n < 0) return;
else
{
print (n);
f (n – 2);
print (n);
f (n – 1);
}
}
Let f(n) be the number of values printed. What is the number of values printed by above function?

Question 3

What is the number of additions in the Fibonacci series of n which uses following recursive function.
fib(n) = fib(n-1) + fib(n-2)

Question 4

Consider the following function.
int fun (int n)

ifreturn (n% 10);
else return fun

What is the return value of fun(9874)?

Question 5

Given a code
void test(int n)
{
int i = 0;
if (n > 1)
test(n-1);
while(n--)
printf(" + ");
}
How many time + will get printed if n = 6;

Question 6

Consider the following C function:

What will the function return when x=4 and y = 2?
• 272 attempts
• 1 upvote
• 1 comment
Jul 23GATE & PSU CS
GradeStack Learning Pvt. Ltd.Windsor IT Park, Tower - A, 2nd Floor, Sector 125, Noida, Uttar Pradesh 201303 bepstudentsupport@byjus.com