c - Return 1 in non main function -


i learning c , have confusion regarding return:

int factorial (int n) {     if (n == 1)         return 1;     else         return n * factorial (n -1); } 

in above recursive code in last call when n 1, return 1 return integer value 1 or error in execution in main. had confusion because return 1 treated differently in main , in function called main...

will return 1 return integer value 1 or error in execution in main?

return 1 returns integer value 1 any function declared return int, even if function happens int main().

a non-zero return value main() interpreted (by execution environment, e.g. shell) indicate error in execution. happens semantic of return value of main().


Comments

Popular posts from this blog

How to get the arclen between two curve points in Maya? -

git svn - Unignore directories in git-svn (adding directories to a sparse checkout) -

C++ Linked List -