2 votes 2 votes Read the below code snippet: int joo( int num ) { int result = 0 ; if ( num <= 1) return 1; else { for ( i=num; i >= 1; i - - ) { result + = joo( i / 3) ; } } return result; } When $num = 6$, the return value of the function is _____. GATE tbb-mockgate-3 programming programming-in-c identify-function numerical-answers + – Bikram asked Feb 9, 2017 retagged Sep 16, 2020 by ajaysoni1924 Bikram 307 views answer comment Share Follow See 1 comment See all 1 1 comment reply chirudeepnamini commented Jan 23, 2020 reply Follow Share for these type of questions ,it would be better to calculate foo(1),foo(2) before hand and later trace the code(dynamic programming) 1 votes 1 votes Please log in or register to add a comment.
Best answer 3 votes 3 votes for i=6 result=result+joo(2) | result+joo[0]=0+1=1 result+joo[0]=1+1=2(for loop executes twice for joo(2)) i=5 result=2+joo(1)=2+1=3; i=4 result=3+joo(1)=4 i=3 result=4+joo(1)=5 i=2 result=5+joo(0)=6 i=1 result=6+joo(0)=7 ans:7 chap24 answered Mar 6, 2017 selected Mar 7, 2017 by Bikram chap24 comment Share Follow See all 0 reply Please log in or register to add a comment.