0
Where does the value of return() goes when we use it in main function?
hi all! I am a student and have recently studied Java . in Java we use return function in any function and it's value goes to the function in which we call function having return statement.but in c++ I am studying I have seen codes where return statement was given in main function. we don't need to call main function so where does the value of return goes.?
3 Réponses
+ 11
The value 0 is returned to the caller of your main function, that is, your operating system (as in C/C++) to signal program termination status.
+ 1
Generally when a main function returns 0; It just means that the program has completed correctly.
It doesn't really "go" anywhere, it just completes the execution.
+ 1
The return type of the main function tells the caller whether the program exits successfully or not (also known as exit code). For Java, the main was called via the JVM (Java Virtual Machine) in order to run the program.