Open In App

Algorithms | Recursion | Question 3

Last Updated : 28 Jun, 2021
Like Article
Like
Save
Share
Report

What does the following function print for n = 25? 

C




void fun(int n)
{
  if (n == 0)
    return;
 
  printf(\"%d\", n%2);
  fun(n/2);


(A)

11001

(B)

10011

(C)

11111

(D)

00000



Answer: (B)

Explanation:

The function mainly prints binary representation in reverse order.  
And the binary representation of 25: 11001
its reverse is = 10011.

Hence (B) is the correct answer.


Quiz of this Question
Please comment below if you find anything wrong in the above post


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads