Function Recursion MCQ Quiz in తెలుగు - Objective Question with Answer for Function Recursion - ముఫ్త్ [PDF] డౌన్‌లోడ్ కరెన్

Last updated on Mar 10, 2025

పొందండి Function Recursion సమాధానాలు మరియు వివరణాత్మక పరిష్కారాలతో బహుళ ఎంపిక ప్రశ్నలు (MCQ క్విజ్). వీటిని ఉచితంగా డౌన్‌లోడ్ చేసుకోండి Function Recursion MCQ క్విజ్ Pdf మరియు బ్యాంకింగ్, SSC, రైల్వే, UPSC, స్టేట్ PSC వంటి మీ రాబోయే పరీక్షల కోసం సిద్ధం చేయండి.

Latest Function Recursion MCQ Objective Questions

Top Function Recursion MCQ Objective Questions

Function Recursion Question 1:

The output of the following program is:

# include

void fun(int x)

{

x = 30;

}

int main()

{

int y = 20;

fun(y);

printf("%d", y);

return 0;

}

  1. 30
  2. 20
  3. Compile error
  4. Run time error

Answer (Detailed Solution Below)

Option 2 : 20

Function Recursion Question 1 Detailed Solution

Parameters are passed by value in C.

Therefore, in the above code, value of y is not modified using the function fun().

To modify the value of a local variable of a function inside another function Pointers are used.

Using pointers, we can modify a local variable of a function inside another function. 

Function Recursion Question 2:

Consider the following ANSI C function:

int SomeFunction (int x, int y)

{

if ( (x == 1) I I (y == 1)) return 1;

if (x == y) return x;

if (x > y) return SomeFunction(x - y, y);

if (y > x) return SomeFunction(x, y - x);

}

The value returned by SomeFunction(15, 255) is _______.

Answer (Detailed Solution Below) 15

Function Recursion Question 2 Detailed Solution

Answer : 15 to 15 

Explanation :

SomeFunction( x, y )

  • SomeFunction( 15, 255 )
  • SomeFunction( 15 , 255-15)
  • SomeFunction( 15, 240 )

{   y > x (255>15)  }

{ again  y > x (240 > 15) }

  • SomeFunction( 15, 225 )

{ again  y > x }

And so on there will be situation when both x and y become equal.

SomeFunction(15, 15 ) -> {  return x; } so 15 will be returned.

Note :

  • In case , If you wondering why call to SomeFunction(15 ,15) will be made? Why this particular call will be in execution flow?
  • because , we encountered SomeFunction(15, 225)  and 152 == 225 ; and we are subtracting 15 from variable y ( y=225) 

Function Recursion Question 3:

Consider the following C functions.

int f1 (int m) {

   static int j = 0;

   if (m > 0) {

      ++j;

      f1(m-1);

   }

   return (j) ;

}

int f2 (int m) {

   static int j = 0;

   if (m > 0) {

      j = j + f1(m) ;

      f2(m-1) ;

   }

   return (j) ;

}

 

The return value of f2(4) is ______

Answer (Detailed Solution Below) 30

Function Recursion Question 3 Detailed Solution

  • Variable ijis static in both the functions thus its value will persist throughout the program.
  • When f2 (4) gets called, it will first call f1 with the value of n as 5 and then f2 will get called with n = 4.
  • Similarly, the same steps are taken for all the upcoming values of n.

 

f2(4) called

0 + fun1 (4)

  • f1 (4) called
  • f1 (3)
  • f1 (2)
  • f1 (1)
  • f(0) -> fun1 (0) returns 0 + 4 = 4.
  • f1 (1) -> 4
  • f1 (2) -> 4
  • f1 (3) -> 4
  • f1 (4) -> 4

 

Fun2 (3) called

4 + fun1 (3)

  • f1 (3) called
  • f1 (2)
  • f1 (1)
  • f1 (0) -> f1 (0) returns 4 + 3 = 7.
  • f1 (1) -> 7
  • f1 (2) -> 7
  • f1 (3) -> 7

 

f2(2) called

4 + 7 + fun1 (3)

  • f1 (2) called
  • f1 (1)
  • f1 (0) -> f1 (0) returns 7 + 2 = 9.
  • f1 (1) -> 9
  • f1 (2) -> 9

 

f2(1) called

4 + 7 + 9 + fun1 (3)

  • f1 (1) called
  • f1 (1)
  • f1 (0) -> f1 (0) returns 9 + 1 = 10.
  • fun1 (1) -> 10

 

f2 (0) called

  • f2 (0) returns 4 + 7 + 9 + 10 = 30
  • f2 (1) -> 30
  • f2 (2) -> 30
  • f2 (3) -> 30
  • f2 (4) -> 30
  • f2 (5) -> 30

Function Recursion Question 4:

Consider the following function written in the C programming language.

void foo(char *a){

if (*a && *a != ‘ ‘){

foo(a+1);

putchar(*a);

}

}

The output of the above function on input “ABCD EFGH” is

  1. ABCD EFGH
  2. ABCD
  3. HGFE DCBA
  4. DCBA

Answer (Detailed Solution Below)

Option 4 : DCBA

Function Recursion Question 4 Detailed Solution

Concept:

If (*a && *a!= ‘ ’)

In this priority of != is greater than && in C. If will break either when a space occurs in the string or a Null ‘\0’ occurs in the string.

Explanation:

Consider the array of string with base address 100:

F1 R.S Madhu 10.01.20 D 1\

 

Recursive call:

F1 R.S Madhu 10.01.20 D 2

Traverse the tree from top to bottom and left to write

Output: DCBA

Function Recursion Question 5:

What is printed by the following program?

#include
void check();
int a = 5;
int main()

a += 4;
check() ;
return 0 ;
}
void check()

++a;
printf("a = %d", a);
}

  1. a = 5
  2. a = 9
  3. a = 6 
  4. a = 10

Answer (Detailed Solution Below)

Option 4 : a = 10

Function Recursion Question 5 Detailed Solution

Code with Explanation:

#include

void check();

int a = 5; / global variable

int main()

{

a += 4; / a = a + 4 = 5 + 4 = 9

check(); / check function is called

return 0;

}

void check()

{

++a; / a = a + 1 = 9 + 1 = 10

printf("a = %d", a); / value 10 is printed

}

Important Points:

a += 4

∴ a = a + 4

++a is a pre increment operator

∴ a = a + 1;

Function Recursion Question 6:

What is the output of the function fun(-1 + 2419)?

#include
int fun(int n)
{
if (n == 0)
return 0;
int temp = n % 10 + fun(n / 10);
if(temp>9)
return fun(temp);
else
return temp;
}
int main() {
printf("%d",fun(-1 + 2419));
return 0;
}

  1. 15
  2. 6
  3. -1
  4. Error

Answer (Detailed Solution Below)

Option 2 : 6

Function Recursion Question 6 Detailed Solution

fun(-1+2419) → fun(2418)

recur1

fun(2418) returns value 15 which is greater than 9. Hence it will call fun(15)

recur2

Function Recursion Question 7:

Consider the following C program:

# include

int counter = 0 ;

int calc (int a, int b) {

int c;

counter++;

if (b==3) return (a*a*a) ;

else {

c = calc (a, b/3) ;

return (c*c*c) ;

}

}

int main ( ) {

      calc (4, 81) ;

      printf (“%d” , counter) ;

}

The output of this program is: ________ .

Answer (Detailed Solution Below) 4

Function Recursion Question 7 Detailed Solution

As counter is a global variable, it can be used anywhere in the program.

When main() calls the calc() with parameter values (4,81) 

counter=counter+1; so now counter=1.

Now for 81, else block got executed and b=81/3=27.

Hence counter = 2

and for 9 it will become 3.

In this way when b=3 counter will become 4 and cacl() return 64;

counter=3

int calc(4,3)

{

int c;

counter++;

if(b==3) return (a*a*a); else { c = calc(a, b/3); return (c*c*c); }

}

Function Recursion Question 8:

In C memory can be deallocated at the runtime. which of the following predefined function can be used to perform this task?

  1. remove();
  2. delete();
  3. free();
  4. terminate();

Answer (Detailed Solution Below)

Option 3 : free();

Function Recursion Question 8 Detailed Solution

free(): 

free operation in C is to tell the compiler this particular memory block is free for the compiler to use for further allocation, but the memory is not released. 

26 June 1

remove():

The C library function int removes (const char *filename) deletes the given filename so that it is no longer accessible.

delete(): 

same as free() but can overload delete implementations. 

Function Recursion Question 9:

Consider the following C code segment

int f (int x)

{

if (x<1) return 1;

else return ( f{x-1) + g(x) );

}

int g (int x)

if (x< 2) return 2;

else return ( f(x-1) + g(x/2));

}

Of the following, which best describes the growth of f(x) as a function of x ?

  1. Linear 
  2. Exponential
  3. Quadratic
  4. Cubic

Answer (Detailed Solution Below)

Option 2 : Exponential

Function Recursion Question 9 Detailed Solution

Explanation

f(n) = f(n-1) + g(n)           ----> 1
g(n) = f(n-1) + g(n/2)       ----> 2

Putting the value of g(n) in equation 1,
f(n) = 2×f(n-1) + g(n) + g(n/2)

So, we can derive the below equation,(by approximation)
f(n) > 2f(n-1)
=> f(n) > 2×2 × f(n-2) ---- because f(n) > 2×f(n-1), so, f(n-1) > 2×2×f(n-2).... so on
=> f(n) > (2n) × f(1) --- here \'^\' denotes the exponent.
So, f(n) > θ(2n)

So, exponential growth for f(x).

correct answer is option 2

Function Recursion Question 10:

What will be the output of the following C program?

#include

void pattern(int x)

{

static int a = 2;

printf("%d", x);

printf("%d", a);

a++;

if(x>1)

pattern(x-1);

printf("%d", a);

}

int main()

{

pattern(4);

}

  1. 4233241566666
  2. 423224156666
  3. 423324156666
  4. 423324153456

Answer (Detailed Solution Below)

Option 3 : 423324156666

Function Recursion Question 10 Detailed Solution

Traverse the below give tree

F1 R.S D.K 20.07.2019 D 1

Traverse the tree in top-down and left to right manner

Output: 423324156666 (Tips: Inorder traversal)

Important Points:

Base condition: x >1
Get Free Access Now
Hot Links: teen patti bliss teen patti joy mod apk teen patti apk