Comments on Linux C Programming Tutorial Part 18: Recursive functions

Irrespective of the programming language you use, as you start coding more and more, you get to learn concepts that make your code crisp and easy to read/understand. There are several such concepts in the C as well. One of them is 'recursive functions,' which we'll be discussing here in this article.

1 Comment(s)

Add comment

Please register in our forum first to comment.

Comments

By: Crito Philippatos

The recursive factorial example above works but I'm having a hard time understanding why it doesn't always return 1. It's like return is being used for two different things, exiting the function with success/true and  actually returning a value.

I tried removing the return 1 just to experiment and the compiler complained with "warning: control reaches end of non-void function", so it's obviously required. I just don't understand why.