+ 1
Here why output is 30?
4 Answers
+ 13
in the link @Sapphire supplied:
https://stackoverflow.com/questions/32513793/c-and-c-functions-without-a-return-statement
especially this possible explanation:
"Odds are what's going on here is that the result of the last expression is getting stored in the same register (on an x86, EAX or RAX) that the compiler is using for the return value of the function. When the function returns, the return instruction leaves this register alone, and the calling code simply assumes the value there is the return value of the function."
above it all, this is called "undefined behaviour", where you would not know what to expect
+ 4
https://stackoverflow.com/questions/1610030/why-does-flowing-off-the-end-of-a-non-void-function-without-returning-a-value-no
In addition to what @Sapphire stated and linked to.
+ 3
Because 10 + 20 is 30.
But I know what you're referring to with the non-returning function.
Technically it's a violation, at least should provide a warning. But simply put, the compiler is unable to tell. There's a similar question to yours with a better explanation on Stackoverflow:
https://stackoverflow.com/questions/32513793/c-and-c-functions-without-a-return-statement