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

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -