yes it multiples two integers but how does it work for example does it if b =3 it minuses b-1 and multiples with 'a' could someone explain that in detail how does that happen becuase if b>1 then return a+ mystery(a,b-1);// how does this recursive call call work

Awesome i couldn't find better explanation than this than anywhere just one tiny thing if b==1 it will return a value so does recursion automatically having storing capabilities like doesnt it lose its determined value 25 and return the intial int a value of 5

Here, when main calls 'foo', foo's body will execute... all it's code will run... and it will return a value (in this example it returns 5).

That value is fed back to the code that called it (here, it gets fed back to main, since main called foo). The function call evaluates to whatever the function returned... so since we are sending the foo() call to cout... we're actually sending the value foo returns to cout. Since foo() returns 5, this will send 5 to cout... which will print 5 to the user.

Recursive calls are no different. A called function gets executed and the returned value gets fed back to whoever calls it. The only change is that the function is calling itself.

So when we call mystery(5,3) from main... the flow works like this:

1) main calls mystery(5,3)
2) mystery(5,3) calls mystery(5,2)
3) mystery(5,2) calls mystery(5,1)
4) mystery(5,1) doesn't call anything, but instead just returns 5
5) execution returns to mystery(5,2), which takes the returned value (5), adds 5 to it, and returns it (returning 10)
6) execution returns to mystery(5,3), which takes the returned value (10), adds 5 to it and returns (returning 15)
7) execution returns to main, with the value of 15 having been returned.

mystery does not "remember" previous calls. Each time you call it, its logic is rerun and its value is recalculated.

at point 4 when mystery returns 5 why will it return execution return again to mystery becuase as u said urself in point 3 mystery is (5,1) and again execution starts again from the value (5,2) and then it adds +1 to b in your point 6 and makes (5,3) and it returns calll back to the main function when b is not even of value 1 now i am in honest confusion