0
return statement
why do we even need the return statement at the end of a C program saying return(0) when we are not using the void function. I mean that I saw programs executing properly even if the return statement is not present.
3 Respuestas
+ 3
So that when you run the program, you get a return value (usually as an error code) from it, which can be used outside of the program.
It doesn't seem to be used a lot, but well, that's how the language was set up.
I think you can - only in the main function - just not write it out, and it will be added for you automatically.
+ 2
You sure it wasn't void function?
+ 2
return gives you back a value, something to be used later instead of just performing an action and printing results to screen but returning nothing.