0
#include <iostream> using namespace std; int main() { cout << "Hello world!"; return 11; } is something wrong
8 Respostas
+ 2
If you look at how the main function is defined:
int main() { return 0; }
^At the beginning, 'int' is the return type of the function, so it expects that you return an 'int.' I believe in the newer standards it may no longer be required, as it's implied instead, but I haven't messed with it in awhile so don't quote me on that.
For the return status, 0 is intended for successful exit status. 1 (or any other number than 0) is intended for a failed exit status.
+ 3
In this scenario, the main function's return statement is simply returning an exit status to your OS. It's purpose won't be noticeable to you for what you're doing here.
+ 1
try it on code playground :)
+ 1
Since the return statement is part of the main function (entry/exit point of the program), it's returning back to the OS itself (which is what called the program/main function).
0
return "11" or return 0 is same ?
i am getting the same output all the time
0
ohk why they had written" return 0" they could also write " return"
0
so do you mean that in this code by return is must as it takes the control out of the function