Value returned be a function in cpp

What is the default value (mind you, not the datatype) returned by a function in cpp if I don’t return a value explicitly?

For eg:

int func(int n)
int main()
   return 0;

In this case the value returned by func() to main().

It’s undefined behaviour (compiler can do whatever it wants). Usually that just means it does nothing and you get whatever value was previously in the register used for return values but it’s not something to rely on.

1 Like

Thanks a lot! :slight_smile: