Here is a simple recursive function that emulates a while loop. In function, I return value in the end step but in the backward step of recursion I don't return value... Function surprisingly does not return NULL value but instead returns the value as it supposed to. Can someone please explain why C permits this?
#include <stdio.h>
int while_recursion(int c) {
c++;
if (c < 10) {
while_recursion(c); // <---------- NOTICE THAT I DON"T RETURN VALUE IN BACKWARD PASS
} else
return c;
}
int main() {
printf("%i\n", while_recursion(0));
return 0;
}