Why our program runs without any errors even we forget to put return 0; in the code? And why the c++ compiler ignores it?
C++ only If an expression is not given on a return statement in a function declared with a non- void return ... For a function of return type void , a return statement is not strictly necessary Return cannot return value and is not needed if your function is declared void. In all other cases, return value; must be present. One exception is main function when it is declared as int main(...) (typical variations include int main(void), int main(int argc, char** argv)). In this case return may be omitted and reaching end of function execution flow is equivalent to implicit return 0;. Even if this is permitted for main, most compilers still emit a warning about it. However, if your main function was defined as void main(...) (which is also permitted), this warning will not appear and this is perfectly ok - again because it was declared as void type.