+ 13
Depends on the return type of the function.
eg.
int main()
{
cout<<"Hello";
return 0; //You must return some value as it's return type is int
}
or
void main()
{
cout<<"Hello again";
}
In second example, return type is void so no need to use return.
+ 3
In computer architecture the purpose of return is so computers know where to go back to once return is called. When a function is called a number goes on a stack behind the scene and return pops the number off the stack indicating where to return to. Any function is allowed to use return void, int, double, etc. Note that when you use return you need to return the same value of the function. The reason you return 0 in main is because main is an int. If your function was a string you would need to return a string. Void is special if you want to return in a void function because you want to exit early write return; Dont return anything simply write return. While also you dont need a return statement in a void function if you so chose.



