Algorithms | Recursion | Question 3

What does the following function print for n = 25?

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


(A) 11001
(B) 10011
(C) 11111
(D) 00000


Answer: (B)

Explanation: The function mainly prints binary representation in reverse order.

Quiz of this Question



My Personal Notes arrow_drop_up


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.