Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  Consider the same recursive C function that t... Start Learning for Free
Consider the same recursive C function that takes two arguments
Q. What is the return value of the function foo when it is called as foo(513, 2)?
  • a)
    9
  • b)
    8
  • c)
    5
  • d)
    2
Correct answer is option 'D'. Can you explain this answer?
Most Upvoted Answer
Consider the same recursive C function that takes two argumentsQ. What...
foo(513, 2) will return 1 + foo(256, 2). All subsequent recursive calls (including foo(256, 2)) will return 0 + foo(n/2, 2) except the last call foo(1, 2). The last call foo(1, 2) returns 1. So, the value returned by foo(513, 2) is 1 + 0 + 0…. + 0 + 1. The function foo(n, 2) basically returns sum of bits (or count of set bits) in the number n.
Free Test
Community Answer
Consider the same recursive C function that takes two argumentsQ. What...
Here in foo(513,2), n=512 and r=2 so if block is executed as n>0, it gives 2+foo(256,2). Now foo(256,2) will return 0+foo(128,0) and so on. At last 0+foo(0,2) will return 0 and so does each function upto foo(256,2). So final result of foo(513,2) will be 2+0=2(option 2)
Explore Courses for Computer Science Engineering (CSE) exam
Question Description
Consider the same recursive C function that takes two argumentsQ. What is the return value of the function foo when it is called as foo(513, 2)?a)9b)8c)5d)2Correct answer is option 'D'. Can you explain this answer? for Computer Science Engineering (CSE) 2025 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about Consider the same recursive C function that takes two argumentsQ. What is the return value of the function foo when it is called as foo(513, 2)?a)9b)8c)5d)2Correct answer is option 'D'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2025 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Consider the same recursive C function that takes two argumentsQ. What is the return value of the function foo when it is called as foo(513, 2)?a)9b)8c)5d)2Correct answer is option 'D'. Can you explain this answer?.
Solutions for Consider the same recursive C function that takes two argumentsQ. What is the return value of the function foo when it is called as foo(513, 2)?a)9b)8c)5d)2Correct answer is option 'D'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of Consider the same recursive C function that takes two argumentsQ. What is the return value of the function foo when it is called as foo(513, 2)?a)9b)8c)5d)2Correct answer is option 'D'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Consider the same recursive C function that takes two argumentsQ. What is the return value of the function foo when it is called as foo(513, 2)?a)9b)8c)5d)2Correct answer is option 'D'. Can you explain this answer?, a detailed solution for Consider the same recursive C function that takes two argumentsQ. What is the return value of the function foo when it is called as foo(513, 2)?a)9b)8c)5d)2Correct answer is option 'D'. Can you explain this answer? has been provided alongside types of Consider the same recursive C function that takes two argumentsQ. What is the return value of the function foo when it is called as foo(513, 2)?a)9b)8c)5d)2Correct answer is option 'D'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Consider the same recursive C function that takes two argumentsQ. What is the return value of the function foo when it is called as foo(513, 2)?a)9b)8c)5d)2Correct answer is option 'D'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam
Signup to solve all Doubts
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev