This is because the C++ standard requires main() to return int.
As you probably know, the return value from the main() function is used by the runtime library as the exit code for the process. Both Unix and Win32 support the concept of a (small) integer returned from a process after it has finished. Returning a value from main() provides one way for the programmer to specify this value.
If the code runs with no error then 0 is returned by the main()
It has to do with the state of the compiler after the execution.
0 means normal termination while 1 means abnormal termination.
Since the compiler needs to know the status of the code it uses the returned 0 or 1, which are of type int.
It can return 1 as well, btw, AJ || ANANT || AC || ANANY || AY
1. You can't use void main in C++ because the standard does not allow it. The main function is declared as int main.
2. The value returned from main is whatever the program designer wants it to be and means whatever the program documentation says it means, which is not always an error. See the documentation for the CHOICE, COMP and FC commands for example.
The value returned can even be negative.
Understanding the concept of a return value from the main function is fundamental to understanding how programs interact with the shell/command line. I suppose that in these days of gui programs people are no longer used to command line usage or shell scripting and batch files.