Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2
On first call f(a, 3) // *a = 12 and *a%2==0 true. So => 12 + f(a+1, 2) // *a now is 7, and *a%2==0 false. => 12 + 7 - f(a+1, 1) // now *a is 5 and *a%2==0 false. => 12 + 7 - 5 - f(a+1, 0) //now *a out of blounds, => 12 + 7 - 5 - 0 = 14
6th Aug 2022, 3:39 PM
Jayakrishna 🇮🇳
+ 3
It's output is 12 + 7 - 5 =14 *a points to first element of array.. On even number calling *a + f(a+1, n-1) On odd number calling *a - f(a+1, n-1) Until n>0.
6th Aug 2022, 3:23 PM
Jayakrishna 🇮🇳