+ 1
Why does main function return 0.
7 Respuestas
+ 4
Main function returns 0 to give a signal to underlying operating system that the function main which is called from the OS is passing test without errors...
+ 1
Because all functions return a value to the function that called it to show that it was successful and that there are no errors.
+ 1
It's some kind of programmers agreement. When program do his work, it must be ended properly. When system see that output value is different that 0, then program probably has ended with error (not always, sometime programmer using that for other purpose )
0
Its the starting point of a code and executes it and its a special type of function meaning "main" is a type of methos that will tell c++ to start there at the main function.
0
return type of main is integer
- 1
because we are taking main function's data type as int , so every data type returns valu except void
- 1
Also it returns 0 because the function void main returns nothing because it hases void in it and that means it doesnt return a value until you write code in it, and soon when you call that function, that code within it will execute