Why does the following code prints 0 in the `main` function without the return statement on the recursive function call:

```
#include <iostream>
using namespace std;

int reverse(int num, int rev = 0)
{
    if(num == 0)
        return rev;
    reverse(num / 10, rev * 10 + (num % 10));
}
int main()
{
    cout << reverse(123);
    return 0;
}

```

But with return statement:

```
#include <iostream>
using namespace std;

int reverse(int num, int rev = 0)
{
    if(num == 0)
        return rev;
    return reverse(num / 10, rev * 10 + (num % 10));
}
int main()
{
    cout << reverse(123);
    return 0;
}

```

It prints 321. I used GDB and value of rev is 321 in both the cases just before returning back to main function then why this difference?