Open In App
Related Articles

ISRO | ISRO CS 2020 | Question 34

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report
Consider the following recursive C function that takes two arguments
unsigned int rer (unsigned int n, unsigned int r) {
  if (n > 0) return (n% r + rer(n/r, r));
  else return 0;
 } 
What is the return value of the function rer when it is called as rer (513, 2) ? (A) 9 (B) 8 (C) 5 (D) 2

Answer: (D)

Explanation:
= rer (513, 2)
= 513% 2 + 256% 2 + 128% 2 + 64% 2 + 32% 2 + 16% 2 + 8%2 + 4%2 + 2%2 + 1%2 
Hence, output will be,
= 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 
= 2 
So, option (D) is correct.

Quiz of this Question

Last Updated : 04 Sep, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads