Why do we have to return always 0 in case the return type of the main() is int. What will happen if we return some integer other than 0?
What you return doesn't intrinsically mean anything as has been stated before, but most OSs take returning 0 to mean that the program has ended with no abnormalities and a non-0 return to mean an abnormal error has occurred. This is mainly so the OS knows to display error notifications and go through the necessary procedures it needs to go through after a program encounters an error.
You can declare your main () as a void function, that way no return value is needed. (This is not very used though) Other than that you can use any integer as your return value. Another case would be for testing your code, like in a switch. Every case could have a different return value as it ends de program. This way you could know precisely which case was evaluated coming from the return int. Hope this helps!
we use return 0 by default to tell that execution has comp successfully.. but according to our program.. if it had some other value to be returned then we can return other values too.. so it depends on the program..
as int has a return type , so you have to return something to the main function for successful execution. return 0 is a standard way of writing, you may return any integer value
returnt 0 is the default return type...however if u have a value to be return u can use the value or result to be return