Can someone exlain me what is that “return” at the end of the function and why we have to write at the end of the main function return 0.e.g
int main()
{
.....
return 0;
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You don’t have to write
returnat the end ofmainin C++; a return value of0is implicit. (This is different in C, where you do have to return a value.)What this does is return a value to the program’s environment, so that it can be known whether the program succeeded (zero) or encountered some error (non-zero). Other programs, including shell scripts/batch files can use this information to make decisions, e.g. they can stop early when an error is encountered in a program they run.